Processing non-SELECT statements
Before building a dynamic SQL non-SELECT statement, verify that this SQL statement is allowed to be run dynamically.
To run a dynamic SQL non-SELECT statement:
- Run the SQL statement using EXECUTE IMMEDIATE, or PREPARE the SQL statement, then EXECUTE the prepared statement.
- Handle any SQL return codes that might result.
The following is an example of an application running a dynamic SQL non-SELECT statement (stmtstrg):
EXEC SQL EXECUTE IMMEDIATE :stmtstrg;
- Using the PREPARE and EXECUTE statements
If the non-SELECT statement does not contain parameter markers, you can run it dynamically using the EXECUTE IMMEDIATE statement. However, if the non-SELECT statement contains parameter markers, run it using the PREPARE and EXECUTE statements.
Parent topic:
Dynamic SQL applications
Related concepts
Dynamic SQL applications
Using interactive SQL