SQL Programming Manual for Pascal
Introduction
HP NonStop SQL Programming Manual for Pascal—528614-001
1-2
Embedding SQL Statements
Embedding SQL Statements
You embed SQL statements by preceding each SQL statement with the keywords
EXEC SQL and by terminating the statement with either a semicolon (;) or Pascal
terminator if a terminator is appropriate for the context. The example below shows
some embedded SQL statements in a Pascal source file:
PROGRAM sample (input,output);
... ; { Pascal variable declarations }
EXEC SQL BEGIN DECLARE SECTION;
... ; { SQL host variable declarations }
EXEC SQL END DECLARE SECTION;
PROCEDURE proc1;
BEGIN
...
EXEC SQL ... ; { DML, DCL, or dynamic SQL statements }
END;
Table 1-1 lists the types and names of the NonStop SQL statements you can embed in
a Pascal program.
Table 1-2 lists the types and names of the host language directives you can embed in a
Pascal program.
Table 1-1. NonStop SQL Statements
Type Statement
Data Control Language (DCL) FREE RESOURCES, LOCK TABLE, UNLOCK
TABLE, CONTROL
Data Definition Language (DDL) ALTER, COMMENT, CREATE, DROP, HELP TEXT,
UPDATE STATISTICS
Data Manipulation Language (DML) CLOSE, DELETE, FETCH, INSERT, OPEN,
SELECT, UPDATE static DECLARE CURSOR
Dynamic SQL Dynamic DECLARE CURSOR, DESCRIBE,
DESCRIBE INPUT, EXECUTE, EXECUTE
IMMEDIATE, PREPARE, RELEASE
Transaction Control BEGIN WORK, COMMIT WORK, ROLLBACK
WORK
Table 1-2. Host Language Directives
Type Directive
Data Declaration BEGIN DECLARE SECTION, END DECLARE SECTION,
INCLUDE SQLCA, INCLUDE SQLDA, INCLUDE SQLSA
Error Checking WHENEVER
Pascal Compiler SQL