Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for C—429847-008
10-15
Input Parameters and Output Variables
Some examples of entries in the names buffer are:
To prompt the user with the parameter names in the input names buffer, you must read
the length of the name and then position a pointer past the length field and onto the
name.
Example 10-2 uses the names buffer, prompts for input, and then reads parameter
values entered by the user.
Complete
Entry
Individual Entry
Part Description
|04|ABCD| |0000000000000100|
|ABCD|
2-byte length 4-character string with value = 4
4-character string
|06|ABCDE | |0000000000000110|
|ABCDE |
2-byte length 4-character string with value = 6
5-character string padded with 1 trailing blank
|00| | |0000000000000000|
| |
2-byte length with value = 0
Null string
Note. If your program accepts null values for input parameters, the indicator parameter names
are included in the names buffer. For more information, see Handling Null Values in Input
Parameters on page 10-17.
Example 10-2. Getting Parameter Values (page1of2)
int request_invars( sqldaptr input_sqlda_ptr,
char *input_namesbuf_ptr )
{
#define data_array_size 21
/* size for numeric parameter value; maximum is 19 */
/* digits plus sign byte plus null byte terminator */
int *len_ptr; /* ptr to access length portion */
/* of names buffer information */
int name_len; /* number of bytes in a */
/* parameter name */
int num_entries; /* number of input parameters */
int i; /* loop counter */
char name_array[31]; /* for null-terminated name of */
/* the input parameter */
char data_array[data_array_size]; /* for a numeric value */
int data_len; /* number of bytes needed in */
/* input value */
int data_read; /* number of bytes of input */
/* value actually read */
char *lastchar; /* last character read */
/* for advancing pointer */
...
num_entries = input_sqlda_ptr->num_entries;
printf("\nPlease provide values for the input
parameters:/n);
...