NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
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 NonStop SQL/MP programming manual for your host language.
Examples—BEGIN DECLARE SECTION
The following example shows a portion of a COBOL85 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.
...
The following 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
COBOL85 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 WORK Statement
BEGIN WORK is a transaction control statement that starts a user-defined TMF
transaction.
A user-defined TMF transaction groups a set of operations on audited objects and files
so that changes made by the operations can be committed (with the COMMIT WORK
statement) or rolled back (with the ROLLBACK WORK statement) as a unit. TMF
transactions do not protect nonaudited tables. See TMF Transactions
on page T-5 for a
detailed discussion of TMF transactions.
BEGIN DECLARE SECTION
BEGIN WORK