SQL Programming Manual for TAL
Dynamic NonStop SQL Operations
HP NonStop SQL Programming Manual for TAL—527887-001
7-8
Overview of a Dynamic SQL Program
Setting Up the Environment
1. Use the DATAPAGES directive to cause the BINSERV process to allocate the
maximum object program data pages (64) for SQL data structures and statement
buffers:
?DATAPAGES 64
2. Copy any required external declarations. Some of these declarations are shown
below; however, your application might need additional declarations.
?SOURCE $system.system.EXTDECS (
! For SQL ! SQLCADISPLAY,
SQLCATOBUFFER,
SQLFSCODE,
SQLGETINFOLIST,
SQLSADISPLAY,
! For startup ! INITIALIZER,
! For memory management ! DEFINEPOOL,
GETPOOL,
PUTPOOL
! For terminal I/O ! MYTERM,
OPEN,
READ,
WRITE,
WRITEREAD
! For data conversion ! NUMIN,
DNUMIN,
FORMATCONVERT,
FORMATDATA,
FNAMEEXPAND,
! For abnormal termination ! ABEND
);
! For data type literals and utility routines (required)
?SOURCE $vol.subvol.TALDECS;
! For run-time and utility routines (optional)
?SEARCH $vol.subvol.TALLIB;
3. Declare the SQLCA and SQLSA data structures:
EXEC SQL INCLUDE SQLCA;
EXEC SQL INCLUDE SQLSA;
4. Declare the SQLDA and names buffers. INCLUDE SQLDA generates a template;
for the names buffer, you must declare your own template. If you do not plan to
allocate the names buffer dynamically, use INCLUDE SQLDA with the
name-string-
size parameter instead of creating your own template.
EXEC SQL INCLUDE SQLDA (sqlda^templ, 1);
STRUCT namesbuf^template(*);
BEGIN
STRING namestr [0:1000];
END;