Invoking SQL Statements | SQL Fundamentals | Teradata Vantage - Invoking SQL Statements - Advanced SQL Engine - Teradata Database

SQL Fundamentals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
uhe1592872955107.ditamap
dita:ditavalPath
uhe1592872955107.ditaval
dita:id
B035-1141
lifecycle
previous
Product Category
Teradata Vantageā„¢
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.

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 Vantage can span any number of input lines. Vantage 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 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.