8.7 UUID Functions
8.7.1 CHAR_TO_UUID()
Available inDSQL, PSQL
Result typeBINARY(16)
Syntax
1. CHAR_TO_UUID (ascii_uuid)
Table 8.7.1.1 CHAR_TO_UUID Function Parameter
| Parameter | Description |
|---|---|
| ascii_uuid | A 36-character representation of UUID. "-" (hyphen) in positions 9, 14, 19 and 24; valid hexadecimal digits in any other positions, e.g. ‘A0bF4E45-3029-2a44-D493-4998c9b439A3’ |
Converts a human-readable 36-char UUID string to the corresponding 16-byte UUID.
8.7.1.1 CHAR_TO_UUID Examples
1. select char_to_uuid('A0bF4E45-3029-2a44-D493-4998c9b439A3') from rdb$database
2. -- returns A0BF4E4530292A44D4934998C9B439A3 (16-byte string)
4. select char_to_uuid('A0bF4E45-3029-2A44-X493-4998c9b439A3') from rdb$database
5. -- error: -Human readable UUID argument for CHAR_TO_UUID must
6. -- have hex digit at position 20 instead of "X (ASCII 88)"
See alsoSection 8.7.3, UUID_TO_CHAR(), Section 8.7.2, GEN_UUID()
8.7.2 GEN_UUID()
Available inDSQL, PSQL
Result typeBINARY(16)
Syntax
1. GEN_UUID ()
Returns a universally unique ID as a 16-byte character string.
8.7.2.1 GEN_UUID Example
1. select gen_uuid() from rdb$database
2. -- returns e.g. 017347BFE212B2479C00FA4323B36320 (16-byte string)
See alsoSection 8.7.3, UUID_TO_CHAR(), Section 8.7.1, CHAR_TO_UUID()
8.7.3 UUID_TO_CHAR()
Available inDSQL, PSQL
Result typeCHAR(36)
Syntax
1. UUID_TO_CHAR (uuid)
Table 8.7.3.1 UUID_TO_CHAR Function Parameters
| Parameter | Description |
|---|---|
| uuid | 16-byte UUID |
Converts a 16-byte UUID to its 36-character, human-readable ASCII representation.
8.7.3.1 UUID_TO_CHAR Examples
1. select uuid_to_char(x'876C45F4569B320DBCB4735AC3509E5F') from rdb$database
2. -- returns '876C45F4-569B-320D-BCB4-735AC3509E5F'
4. select uuid_to_char(gen_uuid()) from rdb$database
5. -- returns e.g. '680D946B-45FF-DB4E-B103-BB5711529B86'
7. select uuid_to_char('Firebird swings!') from rdb$database
8. -- returns '46697265-6269-7264-2073-77696E677321'
See alsoSection 8.7.1, CHAR_TO_UUID(), Section 8.7.2, GEN_UUID()
