SQL/MP Reference Manual
HP NonStop SQL/MP Reference Manual—523352-013
S-77
Static SQL
Static SQL
Static SQL is a form of embedded SQL in which SQL statements are coded directly
into a host language source program.
Static SQL statements begin with EXEC SQL and end with one of these statement
terminators:
Unlike dynamic SQL statements, which can be constructed during program execution,
static SQL statements must be coded directly in the host language program before
compilation.
You can code static SQL statements to refer to different data bases during different
executions by specifying table and view names with DEFINEs and using CONTROL
QUERY to request execution-time name resolution, but the SQL statements
themselves remain unchanged (“static”) from execution to execution.
For more information about using static SQL, see the SQL/MP programming manual
for one of the host languages.
This is an example of a static SQL statement from a COBOL program:
EXEC SQL
SELECT LAST_NAME, EMPNUM INTO :LNAME, :EMPNUM
FROM EMPLOYEE WHERE DEPTNUM = 200
END-EXEC.
This is an example of a static SQL statement from a C, Pascal, or TAL program:
EXEC SQL
SELECT LAST_NAME, EMPNUM INTO :LNAME, :EMPNUM
FROM EMPLOYEE WHERE DEPTNUM = 200;
Table S-4. Summary of SQL Statements
Command Action
* Can be used only in program
; Occurs in C, Pascal, and TAL programs
END-EXEC. Occurs in COBOL programs