EGL creates implicit SQL statements whenever you use an EGL data-access statement (such as add or get) that specifies an SQL record variable as its target. This feature enables you to write functions that access a relational database even if you do not know any SQL at all. It also enables you to generate default SQL code that you can customize.
EGL can also display a default SELECT statement based on an SQL Record definition.
The opposite of an implicit SQL statement is an embedded SQL statement. Here you include explicit SQL code as part of an EGL I/O statement that is introduced by a #sql directive. For details of the #sql syntax, see #sql directive.
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 };