Was this helpful?
Dynamic Programming
Dynamic programming enables embedded OpenSQL programs to specify a variety of program elements (such as queries and OpenSQL statements) at runtime. In applications where table names or column names are not known until runtime, or where complete queries must be built based on the application's runtime environment, the hard‑coded OpenSQL statement is not sufficient. For example, an application might include an expert mode in which the runtime user can type in select queries and browse the results at the terminal. To support applications such as these, OpenSQL provides dynamic OpenSQL.
Dynamic OpenSQL provides the ability to specify table and column names and build queries at runtime. Using dynamic OpenSQL, you can:
Execute a statement that is stored in a buffer (EXECUTE IMMEDIATE)
Encode a statement stored in a buffer and execute it many times (PREPARE and EXECUTE)
Obtain information about a table at runtime (PREPARE and DESCRIBE)
For details about the EXECUTE IMMEDIATE, PREPARE, EXECUTE and DESCRIBE statements, see Dynamic OpenSQL Statements.
To support dynamic SELECT statements, the cursor statements (for example, DECLARE and OPEN) have dynamic versions. For details, see How to Execute a Dynamic Select Statement and Retrieve the Results Using a Cursor.
Last modified date: 04/03/2024