Declaring ROWID variables in ILE RPG applications that use SQL

ILE RPG does not have a variable that corresponds to the SQL data type ROWID.

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. ROWID declarations can be either standalone or within a data structure.

ROWID example

  • The following declaration in free-form:

    results in the following generation:

  • The following declaration in fixed-form:
      D MY_ROWID         S          SQLTYPE(ROWID)

    results in the following generation:

      D MY_ROWID         S          40A  VARYING CCSID(*HEX)
  1. SQLTYPE, ROWID can be in mixed case.
  2. ROWID 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 ROWID 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 ROWID is declared in a host structure.
  6. ROWID host variables cannot be initialized.