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 #247 background imageLoading...
Page #247 background image
Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for C—429847-008
10-49
Detailed Dynamic SQL Program
300 /* *************************************************** */
301 /* FUNCTION request_invars */
302 /* This function accepts the input sqlda and the */
303 /* input names buffer as parameters and requests the */
304 /* input values for the needed input parameters */
305 /* */
306 /* Return: 0 if successful */
307 /* -1 if failure */
308 /* */
309 /* *************************************************** */
310
311 int request_invars ( sqldaptr sqlda, /* ptr to input sqlda */
312 char *nb ) /* ptr to names buffer */
313
314 { /* begin request_invars */
315
316 short *len_ptr; /* int ptr to get the length */
317 /* from the names buffer */
318 /* and write len prefix to */
319 /* varchar data buffers */
320 short name_len; /* num bytes in a name */
321 short num_entries; /* number of sqlvar entries */
322 short i; /* loop index */
323
324 #define data_array_size 21
325 char data_array[data_array_size];
326 /* buffer to get numeric data */
327 /* max 19 digits + sign byte */
328 /* + null terminator */
329 short data_len; /* #bytes of input data needed*/
330 short data_read; /* #bytes of input read */
331 char name_array[31]; /* buffer to contain null */
332 /* terminated name of the */
333 /* input param (without the */
334 /* leading '?' ) */
335 char *lastchar;
336 char *dummy;
337
338 num_entries = sqlda->num_entries;
339 printf( "\nPlease provide data for input params \n");
340 printf( "------------------------------------ \n\n");
341 fflush( stdout);
342
343 for (i=0; i < num_entries; i++)
344 {
345 len_ptr = (short *) nb; /* get to length prefix */
346 name_len = *len_ptr;
347 nb += 2; /* advance nb to skip the */
348 /* 2-byte length prefix */
349
350 /* sanity check */
351 if (name_len > 30)
352 { printf("**** Error: Param name is too long. Try again.\n");
353 fflush( stdout );
354 return (-1);
355 }
356
357 /* get null terminated param name in name_array */
358 if (name_len == 0)
359 name_array[0] = '\0'; /* unnamed param */
360 else
361 {
Example 10-8. Detailed Dynamic SQL Program (page 6 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