Restrictions on Valid Statements
The following restrictions apply to the statements contained in
the character expression, quoted string, or statement variable that
immediately follows the EXECUTE IMMEDIATE keywords:
- The SQL statement cannot contain a host-language comment.
- Names of host-language variables are not recognized as such in
prepared text.
The only identifiers that you can use are names registered in the system catalog of the current database, such as table names and column names.
- The statement cannot reference a host-variable list or a descriptor; it must not contain any question-mark ( ? ) placeholders, which are allowed with a PREPARE statement.
- The text must not include any embedded SQL statement
prefix, such as the dollar sign ( $ ) or the keywords EXEC SQL.
Although it is not required, the SQL statement terminator ( ; ) can be included in the statement text.
- A SELECT or INSERT statement specified within the EXECUTE IMMEDIATE
statement cannot contain a Collection-Derived Table clause.
EXECUTE IMMEDIATE cannot process input host variables, which are required for a collection variable. Use the EXECUTE statement or a cursor to process prepared accesses to collection variables.