Whether specified as a string expression or as a host variable, the dynamic SQL statement can be no longer than 32000 characters.
If specified as a host variable, the statement_string_variable must follow the rules for SQL strings for the client programming language, as given in the following table:
| Language | statement_string |
|---|---|
| COBOL | Non-numeric literal. |
| C | |
| PL/I | Character string expression. |
If the statement string variable is VARCHAR, the statement text cannot be longer than 64K.
The dynamic SQL statement must be a single SQL statement, not a multiple-statement request.
Performing an EXECUTE IMMEDIATE is equivalent to performing a PREPARE followed by an EXECUTE of an unnamed dynamic single non-macro, non-data returning statement.
EXECUTE IMMEDIATE is designed to provide for this special case.
The dynamic SQL statement:
- Cannot be any of the following specific SQL statements:
- ABORT
- BEGIN TRANSACTION
- CHECKPOINT
- CLOSE
- COMMIT
- DESCRIBE
- ECHO
- END TRANSACTION
- EXECUTE
- EXECUTE IMMEDIATE
- FETCH
- LOGOFF
- LOGON
- OPEN
- POSITION
- PREPARE
- REWIND
- ROLLBACK
- Cannot be a data returning statement.
- Cannot be a Preprocessor2 declarative.
- Cannot include host variable references.
- Requires a dynamic cursor when run dynamically.