SQL/MP Programming Manual for COBOL85
Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for COBOL85—429326-004
10-28
Prompting the User for Input Values
Example 10-2 prompts for input.
Handling Null Values in Input Parameters
If your program handles null values on input, each parameter in the statement entered 
by the user or constructed by your program must have a corresponding indicator 
parameter to handle possible null values, or a run-time error will occur when a null 
value is encountered. 
Example 10-2. Prompting for Input
 DATA DIVISION.
 ...
 01 NAME PIC X(30).
 01 NAME-IX PIC S9(4) COMP.
* This variable will store the 2-byte length field:
 01 NAMESIZEX PIC X(2).
* This variable redefines the 2-byte length field
* as an integer so you can perform arithmetic to advance
* through the buffer:
 01 NAMESIZE REDEFINES NAMESIZEX PIC S9(4) COMP.
 PROCEDURE DIVISION.
 ...
 DISPLAY "ENTER PARAMETER VALUES: "
 MOVE 1 TO NAME-IX
* In PERFORM loop for a number of iterations equal to
* INPUT-NUM OF SQLSA:
* Store the 2-byte length field in variable NAMESIZEX:
 MOVE IN-NAMESBUF (NAME-IX : 1) TO NAMESIZEX (1 : 1)
 MOVE IN-NAMESBUF (NAME-IX + 1 : 1) TO NAMESIZEX (2 : 1)
* Move pointer NAME-IX past the LENGTH field and onto the 
 name:
 COMPUTE NAME-IX = NAME-IX + 2
* If NAMESIZE > 0, display the name with a prompt character:
 MOVE SPACE TO NAME
 MOVE IN-NAMESBUF( NAME-IX : NAMESIZE ) TO NAME
 DISPLAY "?", NAME
* Position to the next length field:
 COMPUTE NAME-IX = NAME-IX + NAMESIZE
* ACCEPT the parameter value according to its data type:
 ...










