EXECUTE IMMEDIATE for Dynamic SQL Statement Usage Notes - Teradata VantageCloud Lake

Lake - Working with SQL

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2025-11-21
dita:mapPath
jbe1714339405530.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
jbe1714339405530

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.