Declare binary host variables in ILE RPG applications that use SQL

ILE RPG 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 SQLTYPE keyword. The SQL precompiler replaces this declaration with an ILE RPG language declaration in the output source member. Binary declarations can be either standalone or within a data structure.

BINARY example

The following declaration:

D MYBINARY			S			SQLTYPE(BINARY:50)

results in the generation of the following code:

D MYBINARY			S				50A

VARBINARY example

The following declaration:

D MYVARBINARY			S				SQLTYPE(VARBINARY:100)

results in the generation of the following code:

D MYVARBINARY			S				100A VARYING
Notes:
  1. For BINARY host variables, the length must be in the range 1 to 32766.
  2. For VARBINARY host variables, the length must be in the range 1 to 32740.
  3. BINARY and VARBINARY host variables are allowed to be declared in host structures.
  4. SQLTYPE, BINARY, and VARBINARY can be in mixed case.
  5. SQLTYPE must be between positions 44 to 80.
  6. When a BINARY or VARBINARY is declared as a standalone host variable, position 24 must contain the character S and position 25 must be blank.
  7. The standalone field indicator S in position 24 should be omitted when a BINARY or VARBINARY host variable is declared in a host structure.