Including Dynamic SQL

Typically, developers include dynamic constructs in Application Engine programs to change SQL based on various runtime factors or on user-defined entries on a page. You can include dynamic SQL in Application Engine programs in a variety of ways. For example, you can:

  • Include dynamic sections using the AESection object.

  • Change SQL using the SQL class.

  • Reference SQL in your own tables.

The AESection class is designed primarily for online section building; therefore, it will not be the most frequently used solution.

Use the SQL class to store SQL in a SQL definition that you can also access in Application Designer. Then, if you have a few SQL statements to run, generate the SQL IDs based on some methodology, such as a timestamp, and then store these in a table.

When the program runs, your SQL could query this table based on process and extract the appropriate SQL IDs to be run with a SQL action in a Do Select loop.

%SQL(%BIND(MY_SQLID, NOQUOTES)) 

For a dynamic Do action, the AE_APPLID and the AE_SECTION fields must appear in the default state record.