Start of change

GENERATE_UUID scalar function

FL 508 The GENERATE_UUID function returns the formatted string representation of a universally unique identifier (UUID) by using the version 4 algorithm.

Read syntax diagramSkip visual syntax diagram GENERATE_UUID ( )

The schema is SYSIBM.

The result of the function is a CHAR(36) value that has the following format:

xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx

Characters in the string are upper case. The CCSID of the result is the SBCS CCSID that is determined from the application encoding scheme.

The result cannot be null. GENERATE_UUID is a non-deterministic function.

Notes for GENERATE_UUID

UUID generation algorithm

Db2 for z/OS® supports generation of UUID values as defined in the version 4 algorithm defined in the RFC 4122 industry standard. For more information about the RFC 4122 industry standard, see https://www.ietf.org/rfc/rfc4122.html.

Converting UUID values

To convert from the CHAR(36) form of a UUID value to a BINARY(16) representation of the value, use the VARBINARY_FORMAT scalar function.

To convert from the BINARY(16) form of a UUID value to the CHAR(36) representation of the value, use the VARCHAR_FORMAT_BINARY scalar function.

Example for GENERATE_UUID

The following statement generates a UUID value as a CHAR(36) string value.

INSERT INTO EMP (ID) 

VALUES (GENERATE_UUID());

The result is similar to the following character string value:

'59CDD884-2C67-4350-AAA0-1A18FBF50B23'
End of change