SQL/MP Programming Manual for COBOL
Host Variables
HP NonStop SQL/MP Programming Manual for COBOL—529758-003
2-7
Using the COBOL PICTURE Clause
Using the COBOL PICTURE Clause 
If you use the PICTURE clause to declare COBOL record descriptions as host 
variables, the clause must conform to both COBOL syntax rules and SQL/MP 
limitations. 
Fixed-Length Character Data 
Use the PICTURE clause to declare a host variable for fixed-length character data 
(CHAR data type): 
PICTURE X (length) [ USAGE IS DISPLAY ]
The length value must be a positive integer and not greater than 4096. Instead of 
length, you can specify multiple Xs, with each X representing one character position, 
or you can specify multiple Xs and lengths as allowed in COBOL. For example, 
PIC XXX(3)X(3) is valid. DISPLAY is the default. 
Variable-Length Character Data 
Use a group item with two data items to declare a host variable for variable-length 
character data (VARCHAR data type): 
nn group-name.
 nm LEN PIC S9(4) COMP.
 nm VAL PIC X(len).
The group-name must follow COBOL naming conventions. The level numbers are 
indicated by nn and nm: nn can be any level in the range 01 to 49, and nm is a 
greater level than nn. LEN specifies the actual length of the character item in VAL. VAL 
is a character data item with len specifying the maximum number of characters that 
can be stored in VAL. 
For example, the EMPLOYEE table has the EMP-NAME column defined as 
VARCHAR(18). In a COBOL program, the column definition is:
05 EMP-NAME. 
 10 LEN PIC S9(4) COMP.
 10 VAL PIC X(18).
In the Procedure Division, you must explicitly move a value to LEN before using 
EMP-NAME in an SQL statement: 
MOVE "SMITH" TO VAL OF EMP-NAME.
MOVE 5 to LEN OF EMP-NAME. 
EXEC SQL INSERT INTO EMPLOYEE-TABLE(EMP_NAME)
 VALUES (:EMP-NAME) 
END-EXEC.










