EasyManuals Logo

HP NonStop SQL/MP User Manual

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
Page #244 background imageLoading...
Page #244 background image
Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for C—429847-008
10-46
Detailed Dynamic SQL Program
119 extern sqldaptr allocate_sqlda ( int num_entries );
120 extern short get_string ( char *data_array,
121 short array_size,
122 short nullit,
123 char terminator );
124 extern char *get_dtname ( short datatype );
125
126 /* *************************************************** */
127 /* FUNCTION display_result */
128 /* This function accepts the output sqlda and the */
129 /* output names buffer as parameters and displays the */
130 /* output of a select statement with the following */
131 /* format: */
132 /* */
133 /* tablename.colname <data retrieved> */
134 /* tablename.colname <data retrieved> */
135 /* */
136 /* The display is currently restricted to at most */
137 /* 38 characters; this restriction can be easily */
138 /* relaxed by wrapping the display lines */
139 /* */
140 /* Return: 0 if successful */
141 /* -1 if failure */
142 /* */
143 /* *************************************************** */
144
145 int display_result ( sqldaptr sqlda, /* ptr to output sqlda */
146 char *nb ) /* ptr to names buffer */
147
148 { /* begin display_result */
149
150 short *len_ptr; /* int ptr to get the length */
151 /* from the names buffer */
152 short name_len; /* num bytes in a name */
153 short num_entries; /* number of sqlvar entries */
154 short i; /* loop index */
155 char data_array[39]; /* buffer to contain data to */
156 /* be displayed (null termi- */
157 /* nated) */
158 char *data_ptr; /* ptr to retrieved data */
159 short data_len; /* data buffer size */
160 char name_array[40]; /* buffer to contain null */
161 /* terminated name in a */
162 /* <tabname>.<colname> format */
163 /* [ 8 + 1 + 30 chars ] */
164 char *lastchar;
165
166 num_entries = sqlda->num_entries;
167
168 for (i=0; i < num_entries; i++)
169 {
170 len_ptr = (short *) nb; /* get to length prefix */
171 name_len = *len_ptr;
172 nb += 2; /* advance nb to skip the */
173 /* 2-byte length prefix */
174
175 /* get null terminated name in name_array */
176 if (name_len == 0)
177 strcpy(name_array, "(EXPR)"); /* default name */
178 else
Example 10-8. Detailed Dynamic SQL Program (page 3 of 22)

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the HP NonStop SQL/MP and is the answer not in the manual?

HP NonStop SQL/MP Specifications

General IconGeneral
BrandHP
ModelNonStop SQL/MP
CategorySoftware
LanguageEnglish

Related product manuals