Declaring result set locator variables in ILE RPG applications that use SQL

ILE RPG does not have a variable that corresponds to the SQL result set locator data type.

To create host variables that can be used with this data type, use the SQLTYPE keyword. The SQL precompiler replaces this declaration with an ILE RPG language declaration in the output source member. Result set locator declarations can be either standalone or within a data structure.

Result set locator example

  • The following declaration in free-form:
      DCL-S RS_LOC1 SQLTYPE(RESULT_SET_LOCATOR);

    results in the following generation:

      DCL-S RS_LOC1 INT(20);
  • The following declaration in fixed-form:
      D RS_LOC1          S          SQLTYPE(RESULT_SET_LOCATOR)

    results in the following generation:

      D RS_LOC1          S          20I 0
Notes:
  1. SQLTYPE, RESULT_SET_LOCATOR can be in mixed case.
  2. Result set locator host variables are allowed to be declared in host structures.
  3. SQLTYPE must be between positions 44 and 80 for fixed-form declarations.
  4. When a result set locator is declared as a standalone host variable, position 24 must contain the character 'S' and position 25 must be blank for fixed-form declarations.
  5. The standalone field indicator 'S' in position 24 for fixed-form declarations should be omitted when a result set locator is declared in a host structure.
  6. Result set locator host variables cannot be initialized.