EasyManua.ls Logo

HP NonStop SQL/MP

HP NonStop SQL/MP
331 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for C429847-008
10-44
Detailed Dynamic SQL Program
The commented program listing appears in Example 10-8.
Example 10-8. Detailed Dynamic SQL Program (page 1 of 22)
1 /***************************************************************/
2 /* */
3 /* This program can accept any DDL or DML statement from the */
4 /* terminal, prepare the statement, prompt for parameter */
5 /* values, run the statement and output the result to the */
6 /* terminal. Records returned from a SELECT operation are */
7 /* displayed with column names */
8 /* */
9 /***************************************************************/
10
11 #pragma inspect
12 #pragma symbols
13 #pragma SQL
14 #pragma xmem
15 #pragma runnable
16
17 #pragma nolist
18 #include <stdioh>
19 #include <stdlibh>
20 #include <stringh>
21 #include <memoryh>
22 #include <cextdecs (SQLCADISPLAY)>
23 #pragma list
24
25 #include <sqlh>
26
27 /***************************************************************/
28 /* Declare Section -- for host variable declarations */
29 /***************************************************************/
30
31 exec sql begin declare section;
32
33 int sqlcode; /* sqlcode (required) */
34 exec sql include sqlca;
35 exec sql include sqlsa;
36
37 /* ----------------------------------------------------------- */
38 /* Include sqlda to get SQLDA_TYPE struct and SQLVAR_TYPE */
39 /* struct declarations */
40 /* ----------------------------------------------------------- */
41 /* Note for SQLDA structure template: */
42 /* ----------------------------------------------------------- */
43 /* */
44 /* The template for sqlda struct (SQLDA_TYPE) is declared to */
45 /* contain 1 sqlvar entry (SQLVAR_TYPE). This is done to get */
46 /* easy addressability to the sqlvars array. When allocating */
47 /* memory for the sqlda and the sqlvars entries, allocate */
48 /* memory for: */
49 /* */
50 /* sizeof( struct SQLDA_TYPE ) + */
51 /* (num_sqlda_entries - 1) * sizeof( struct SQLVAR_TYPE ) */
52 /* */
53 /* ----------------------------------------------------------- */
54 exec sql include sqlda (dummy_da, 1, dummy_names, 1);
55
56 typedef struct SQLDA_TYPE *sqldaptr;
57

Table of Contents

Related product manuals