SQL/MP Programming Manual for COBOL

Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for COBOL529758-003
10-33
Displaying Output
For input, this sequence was described in Prompting the User for Input Values on
page 10-24:
1. Get the length of the parameter name.
2. Advance to the name.
3. Display the name and ask for a value for that name.
4. Interpret the value entered according to data type.
To display output, one possible sequence is:
1. Get the length of the column name.
2. Advance to the name.
3. Interpret the data type of the column value.
4. Display the name with the value.
This sequence displays names and values repetitively. For example:
EMPNUM 2000
EMPNAME MARILYN ROBERTS
EMPNUM 1566
EMPNAME CATHERINE WILLIAMS
EMPNUM 1890
EMPNAME RICHARD JONES
Displaying Names as Headings
Another possible sequence for displaying output would show the column names as
headings, the way SQLCI does. To do this, loop (OUTPUT-NUM OF SQLSA) times:
Get the length of the column name.
Advance to the name.
Display the name with some blank space.
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.
Using DATA-TYPE to Evaluate Column Values
You can use DATA-TYPE to evaluate SELECT column values before displaying values.
The code shown in Example 10-3 on page 10-34 illustrates one way to do this. This
code displays the column names repetitively rather than displaying all the names as
headings as SQLCI does.