SQL$HELP_OLD72.HLB  —  Built In Functions, SYS_GUID
    The SYS_GUID function returns a 16 octet globally unique
    identifier. Applications would use this to provide unique values
    from various applications and across databases in an OpenVMS
    cluster or network.

    This function uses the OpenVMS system service SYS$CREATE_UID.
    Applications that call this system service create compatible
    values for Rdb.

    The returned value from SYS_GUID() may contain octets that
    are zero. If returning values to C applications, then Oracle
    recommends using the $SQL_VARCHAR pseudo type to avoid C null
    terminated string semantics.

    The SYS_GUID() returns data using a special character set. This
    special character set is used by Oracle Rdb to distinguish this
    type of string from others. Interactive SQL will format the value
    using standard OpenVMS formatting services when this character
    set is seen. Note that these services perform reordering of the
    octet values during formatting, that is, the value isn't a direct
    hexadecimal representation of the value.

    Database administrators can define a domain to be used by
    applications which will make it easier to use.

    SQL> create domain GUID_DOMAIN
    cont>    char(16) character set -11;
    SQL>
    SQL show domain GUID_DOMAIN;
    GUID_DOMAIN                     CHAR(16)
             GUID 16 Characters,  16 Octets
    SQL>

    This domain can be used for column, parameter, and variable
    definitions.

    To support storing literal GUID values, SQL also supports GUID
    literals. The literals follow the standard literal format using
    the special prefix _GUID, as shown in the following examples.

    SQL> create domain GUID_DOMAIN
    cont>    char(16) character set -11;
    SQL> show domain GUID_DOMAIN;
    GUID_DOMAIN                     CHAR(16)
             GUID 16 Characters,  16 Octets

    SQL> create table SAMPLE
    cont>     (a int
    cont>     ,b GUID_DOMAIN default _guid'00000000-0000-0000-0000-000000000000');
    SQL> insert into SAMPLE default values;
    1 row inserted

    SQL> show table (column) SAMPLE;
    Information for table SAMPLE

    Columns for table SAMPLE:
    Column Name                     Data Type        Domain
    -----------                     ---------        ------
    A                               INTEGER
    B                               CHAR(16)         GUID_DOMAIN
             GUID 16 Characters,  16 Octets
     Oracle Rdb default: GUID'00000000-0000-0000-0000-000000000000'
    SQL>

    The literal can also be used in queries to select existing rows.

    SQL> select * from SAMPLE
    cont> where b = _guid'3DBB657F-8513-11DF-9B74-0008029189E7';
Close Help