SQL Programming Manual for Pascal

Using Dynamic SQL
HP NonStop SQL Programming Manual for Pascal528614-001
7-31
Displaying Output
4. Read the DATA_TYPE field from the SQLVAR array to get the data type of the
column value to be written.
5. Retrieve the value from the location pointed to by the VAR_PTR field in the
SQLVAR array. Format the value and write it to output. The steps to use depend on
the data type of the value.
The sequence just described displays names and values repetitively; for example:
EMPNUM 2000
EMPNAME JANE ROBERTS
EMPNUM 1566
EMPNAME CATHERINE WILLIAMS
EMPNUM 1890
EMPNAME RICHARD SMITH
Another possible sequence for displaying output would show the column names as
headings, the way SQLCI does, by executing the following loop.
Assume that the value in SQLSA.PREPARE.OUTPUT_NUM was saved
in variable outnum. Loop outnum times:
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 will need to 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 (listed and described under Allocating Memory for the
Values on page 7-22) to decide how to display output column values.
Figure 7-9
shows sample code for displaying output.