15.00 - Invoking SQL Statements - Teradata Database

Teradata Database SQL Fundamentals

prodname
Teradata Database
vrm_release
15.00
category
Programming Reference
featnum
B035-1141-015K

Invoking SQL Statements

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:

  • SELECT
  • CREATE TABLE
  • COMMIT
  • CONNECT
  • PREPARE
  • 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.

    Examples of nonexecutable SQL statements for embedded SQL applications include:

  • DECLARE CURSOR
  • BEGIN DECLARE SECTION
  • END DECLARE SECTION
  • EXEC SQL
  • Examples of nonexecutable SQL statements for stored procedures include:

  • DECLARE CURSOR
  • DECLARE
  • SQL Requests

    A request to Teradata Database can span any number of input lines. Teradata Database can receive and perform SQL statements that are:

  • 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.