Example 10-6. Displaying Output - HP NonStop SQL/MP Programming Manual

For c
Table of Contents

Advertisement

Dynamic SQL Operations
EMPNAME
CATHERINE WILLIAMS
EMPNUM
1890
EMPNAME
RICHARD SMITH
You can also display the column names as headings (similar to SQLCI) by executing
this loop for output_num iterations:
1. Get the length of the column name.
2. Advance to the name.
3. Display the name with some blank space.
4. Advance to the next length field.
If you use this second method, you must execute a second loop to interpret and
display the values, including enough blank space for each value to fall under its column
heading.
You can use data type literals to decide how to display output column values.
Example 10-6
Example 10-6. Displaying Output (page 1 of 2)
/* Declare, open, fetch, and close the cursor. */
/* (for code, see sample program)
int display_result ( sqldaptr output_sqlda_ptr,
{
int *len_ptr;
int name_len;
int num_entries;
int i;
char
data_array[39]; /* Buffer to contain data to be
char
*data_ptr;
int data_len;
char
name_array[40]; /* Buffer for null terminated
char
*lastchar;
HP NonStop SQL/MP Programming Manual for C—429847-008
displays output.
char *output_namesbuf_ptr )
/* Pointer to get length info
/*
/* Number of bytes in column name
/* Number of columns to be output
/*
/*
/* Pointer to retrieved data
/* Data buffer size
/*
/*
/*
/* Last character read
Allocate and Fill In Output Variables
from the names buffer
loop counter
displayed (null terminated)
column name, in the format
tablename.colname
( 8
+ 1 + 30 characters )
10-34
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/

Advertisement

Table of Contents
loading

Table of Contents