Dynamic SQL with EXECUTE and EXECUTE IMMEDIATE

Database
Enthusiast

Dynamic SQL with EXECUTE and EXECUTE IMMEDIATE

What are the differences between EXECUTE and EXECUTE IMMEDITATE, is I can’t see any difference in the supplied documentation...

Properties of EXECUTE, EXECUTE IMMEDIATE and dbc.SysExecSql are:

  • All can be called multiple times in a statement.
  • None can be used to return a result set
  • EXECUTE & EXECUTE IMMEDIATE are ANSI 2008 compliant.
2 REPLIES
Teradata Employee

Re: Dynamic SQL with EXECUTE and EXECUTE IMMEDIATE

EXECUTE IMMEDIATE is the ANSI equivalent of Teradata "CALL dbc.SysExecSQL()". [The argument for either is a character string that contains a SQL statement.]

EXECUTE requires separate PREPARE statement, and allows parameter values to be passed (USING). [The argument for EXECUTE is a "prepared SQL statement" object.]

All three statement types can be used multiple times in one stored procedure.

Enthusiast

Re: Dynamic SQL with EXECUTE and EXECUTE IMMEDIATE

Perfect Fred, - thank you for that clarification regarding argument lists.