Dynamic SQL
The SQL statement associated with an EGL statement can be specified statically, with every detail in place at generation time. When dynamic SQL is in effect, however, the SQL statement is built at run time, each time that the EGL statement is invoked.
Use of dynamic SQL decreases the speed of run-time processing, but lets you vary a database operation in response to a run-time value:
- For a database query, you may want to vary the selection criteria, how data is aggregated, or the order in which rows are returned; those details are controlled by the WHERE, HAVING, GROUP BY, and ORDER BY clauses. In this case, you can use the prepare statement.
- For many kinds of operations, you may want a run-time value to determine which table to access. You can accomplish dynamic specification of a table in either of two ways:
- Use the prepare statement; or
- Use an SQL record and specify a value for the property tableNameVariables, as described in SQL record part in EGL source format.
Related concepts
SQL support
Related reference
Database authorization and table names
prepare
SQL record part in EGL source format