Binary host variables in PL/I applications that use SQL

PL/I does not have variables that correspond to the SQL binary data types. To create host variables that can be used with these data types, use the SQL TYPE IS clause. The SQL precompiler replaces this declaration with a PL/I language structure in the output source member.

BINARY and VARBINARY

Read syntax diagramSkip visual syntax diagram
>>-+-DECLARE-+--+-variable-name-----------+--------------------->
   '-DCL-----'  | .-,-------------------. |   
                | V                     | |   
                '---(--variable-name--)-+-'   

>--SQL TYPE IS--+-BINARY---------+--(--length--)--;------------><
                +-VARBINARY------+                    
                '-BINARY VARYING-'                    

Notes:
  1. For BINARY host variables, the length must be in the range 1 to 32766.
  2. For VARBINARY and BINARY VARYING host variables, the length must be in the range 1 to 32740.
  3. SQL TYPE IS, BINARY, VARBINARY, BINARY VARYING can be in mixed case.

BINARY Example

The following declaration:

 DCL MY_BINARY SQL TYPE IS BINARY(100);

Results in the generation of the following code:

DCL MY_BINARY CHARACTER(100);

VARBINARY Example

The following declaration:

 DCL MY_VARBINARY SQL TYPE IS VARBINARY(250);

Results in the generation of the following code:

DCL MY_VARBINARY CHARACTER(250) VARYING;