SQL Programming Manual for TAL

Introduction
HP NonStop SQL Programming Manual for TAL527887-001
1-2
Developing a Program
Developing a Program
A TAL program that contains embedded SQL statements can use both static and
dynamic SQL operations. A static SQL operation processes SQL statements that you
embed and compile in the TAL source code. A dynamic SQL operation enables a
program to construct, compile, and execute an SQL statement at run time.
Embedding SQL Statements
You embed SQL statements by preceding each SQL statement with the keywords
EXEC SQL and terminating the statement with either a semicolon (;) or an END, ELSE,
or UNTIL keyword if it is appropriate for the statement. This example shows a TAL
source file that contains embedded SQL statements.
! TAL source file
...
EXEC SQL BEGIN DECLARE SECTION;
... ; ! SQL host variable declarations
EXEC SQL END DECLARE SECTION;
...
! TAL procedure
...
EXEC SQL ... ; ! SQL statement
...
Table 1-1 shows the NonStop SQL statements you can embed in a TAL program.
Table 1-1. NonStop SQL Statements
Type Statement
Data Control Language (DCL) FREE RESOURCES, LOCK TABLE, UNLOCK
TABLE
Data Definition Language (DDL) ALTER, COMMENT, CREATE, DROP, HELP TEXT,
UPDATE STATISTICS
Data Manipulation Language (DML) CLOSE, DECLARE CURSOR, DELETE, FETCH,
INSERT, OPEN, SELECT, UPDATE
Dynamic SQL DECLARE CURSOR, DESCRIBE, DESCRIBE
INPUT, EXECUTE, EXECUTE IMMEDIATE,
PREPARE, RELEASE
Transaction Control BEGIN WORK, COMMIT WORK, ROLLBACK
WORK