SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
B-2
BEGIN DECLARE SECTION Directive
BEGIN DECLARE SECTION Directive
BEGIN DECLARE SECTION is a host program directive that starts a host program
Declare Section for declaring host variables to use in SQL statements.
Guidelines for the use of Declare Sections vary with the host language. For more
information, see the SQL/MP programming manual for your host language.
Examples—BEGIN DECLARE SECTION
This example shows a portion of a COBOL Working Storage Section that includes
an SQL Declare Section. Variables declared within the Working Storage Section
but outside the SQL Declare Section cannot be used in SQL statements.
WORKING-STORAGE SECTION.
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 SUPPLIER PIC 999.
01 ORDERS OCCURS 10 TIMES.
05 ORDERNUM PIC 999 COMP.
05 DT DATE.
EXEC SQL END DECLARE SECTION END-EXEC.
...
This example shows a Declare Section that uses an INVOKE directive to declare a
table as a record description in a C, Pascal, or TAL program. (A COBOL version
would use END-EXEC. in place of each semicolon.)
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL INVOKE SALES.PARTS;
EXEC SQL END DECLARE SECTION;
BEGIN DECLARE SECTION