The ROWID function casts a character string to a row ID.

Read syntax diagramSkip visual syntax diagramROWID (string-expression)
An expression that returns a character string value. Although the string can contain any value, it is recommended that it contain a ROWID value that was previously generated by DB2® for z/OS® or Db2® for i to ensure a valid ROWID value is returned. For example, the function can be used to convert a ROWID value that was cast to a CHAR value back to a ROWID value.

If the actual length of string-expression is less than 40, the result is not padded. If the actual length of string-expression is greater than 40, the result is truncated. If non-blank characters are truncated, a warning is returned.

The length attribute of the result is 40. The actual length of the result is the length of string-expression.

The result of the function is a row ID. If the argument can be null, the result can be null; if the argument is null, the result is the null value.


Syntax alternatives: The CAST specification should be used to increase the portability of applications. For more information, see CAST specification.


  • Assume that table EMPLOYEE contains a ROWID column EMP_ROWID. Also assume that the table contains a row that is identified by a row ID value that is equivalent to X'F0DFD230E3C0D80D81C201AA0A280100000000000203'. Using direct row access, select the employee number for that row.
        WHERE EMP_ROWID = ROWID(X'F0DFD230E3C0D80D81C201AA0A280100000000000203')