SQL/MP Programming Manual for COBOL

Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for COBOL529758-003
10-25
Prompting the User for Input Values
Example 10-1. Evaluating Input Parameter Values (page 1 of 2)
DATA DIVISION.
* Loop counter:
01 INDEX PIC S9(4) COMP.
* Define storage for all possible data types. The VAR-PTR
* field in the input SQLDA points to this storage.
01 PARAM-REC.
02 PARAMS OCCURS 20 TIMES.
03 P PIC X(60).
03 PCHAR REDEFINES P PIC X(60).
03 PVARCHAR REDEFINES P.
04 LEN PIC S9(4) COMP.
04 VAL PIC X(58).
03 PNUMERIC REDEFINES P PIC S9(15)V9(3) COMP.
03 PINT REDEFINES P PIC 9(9) COMP.
03 PDECIMAL REDEFINES P PIC S9(9)V9(3) DISPLAY.
03 PLARGINT REDEFINES P PIC 9(18) COMP.
03 PSMLINT REDEFINES P PIC 9(4) COMP.
PROCEDURE DIVISION.
MOVE 1 TO INDEX
...
PERFORM UNTIL INDEX IS > INPUT-NUM OF SQLSA
...
* Check for character data type:
* Guard against the case where the database column is longer
* than the data variable in Working-Storage.
IF DATA-TYPE OF SQLVAR OF IN-SQLDA(INDEX) < 64
ACCEPT PCHAR OF PARAMS(INDEX)
IF DATA-LEN OF IN-SQLDA(INDEX) > 60
MOVE 60 TO DATA-LEN OF SQLVAR OF IN-SQLDA(INDEX)
END-IF