ターゲットとして SQL レコード変数を指定する EGL データ・アクセス・ステートメント (add、get など) を使用すると、EGL は暗黙の SQL ステートメントを常に作成します。この機能により、SQL に関する知識が一切ないユーザーであっても、リレーショナル・データベースにアクセスする関数を作成できるようになります。また、デフォルトの SQL コードを生成して、それをカスタマイズすることもできます。
EGL では、SQL レコード定義に基づくデフォルトの SELECT ステートメントを表示することもできます。
組み込み SQL ステートメントは、暗黙的な SQL ステートメントとは対照的です。 ここでは、#sql ディレクティブで導入された明示的な SQL コードを、EGL I/O ステートメントの一部として組み込みます。 #sql 構文の詳細については、sql ディレクティブを参照してください。
record CustomerRecord type SQLRecord
{tableNames = [["ADMINISTRATOR.CUSTOMER", "L1"]],
keyItems = [customerNumber]}
customerNumber STRING {column="C_NUMBER", maxLen=6};
customerName STRING {column="C_NAME", isSQLNullable=yes, maxLen=25};
customerAddr1 STRING {column="C_ADDR1", isSQLNullable=yes, maxLen=25};
customerAddr2 STRING {column="C_ADDR2", isSQLNullable=yes, maxLen=25};
customerAddr3 STRING {column="C_ADDR3", isSQLNullable=yes, maxLen=25};
customerBalance MONEY {column="C_BALANCE", isSQLNullable=yes};
end
get myCustomer with #sql{
select
C_NUMBER, C_NAME, C_ADDR1, C_ADDR2, C_ADDR3, C_BALANCE
from ADMINISTRATOR.CUSTOMER L1
where
C_NUMBER = :myCustomer.customerNumber
};
get myCustomer
into myCustomer.customerNumber, myCustomer.customerName,
myCustomer.customerAddr1, myCustomer.customerAddr2,
myCustomer.customerAddr3, myCustomer.customerBalance with
#sql{
select
C_NUMBER, C_NAME, C_ADDR1, C_ADDR2, C_ADDR3, C_BALANCE
from ADMINISTRATOR.CUSTOMER L1
where
C_NUMBER = :myCustomer.customerNumber
};