How to Execute a Dynamic Nonselect Statement
To execute a dynamic non‑select statement, use either the EXECUTE IMMEDIATE statement or the PREPARE and EXECUTE statements. EXECUTE IMMEDIATE is most useful if the program executes the statement only once within a transaction. If the program executes the statement many times within a transaction, for example, within a program loop, use the PREPARE and EXECUTE combination: prepare the statement once, then execute as many times as necessary.
If the program does not know whether the statement is a SELECT statement, the program can prepare and describe the statement. The results returned by the DESCRIBE statement will indicate whether the statement was a select. For more information and a sample of the conditional coding to handle such situations, see
Executing the Select with Execute Immediate.
Last modified date: 01/30/2023