SQL provides several ways to invoke an executable SQL statement:
- Interactively from a terminal
- Embedded within an application program
- Dynamically performed from within an embedded application
- Embedded within a stored procedure or external stored procedure
Executable SQL Statements
An executable SQL statement performs an action. The action can be on data or on a transaction or some other entity at a higher level than raw data.
Some examples of executable SQL statements include:
- CREATE TABLE
Most executable SQL statements can be performed interactively from a terminal using an SQL query manager like BTEQ or Teradata SQL Assistant.
The following types of executable SQL commands cannot be performed interactively:
- Cursor control and declaration statements
- Dynamic SQL control statements
- Stored procedure control statements and condition handlers
- Connection control statements
- Special forms of SQL statements such as SELECT INTO
These statements can only be used within an embedded SQL or stored procedure application.
Nonexecutable SQL Statements
A nonexecutable SQL statement is one that declares an SQL statement, object, or host or local variable to the preprocessor or stored procedure compiler. Nonexecutable SQL statements are not processed during program execution.
- DECLARE CURSOR
- BEGIN DECLARE SECTION
- END DECLARE SECTION
- EXEC SQL
- DECLARE CURSOR
- Embedded in a client application program that is written in a procedural language.
- Embedded in a stored procedure.
- Entered interactively through BTEQ or Teradata SQL Assistant interfaces.
- Submitted in a BTEQ script as a batch job.
- Submitted through other supported methods (such as CLIv2, ODBC, and JDBC).
- Submitted from a C or C++ external stored procedure using CLIv2 or a Java external stored procedure using JDBC.