Oracle CON_GUID_TO_ID() Function

Oracle CON_GUID_TO_ID() is a built-in function that returns the container ID based on the container GUID.

Oracle CON_GUID_TO_ID() Syntax

Here is the syntax for the Oracle CON_GUID_TO_ID() function:

CON_GUID_TO_ID(container_guid)

Parameters

container_guid

Required. The container GUID. It is a raw value.

Return Value

The Oracle CON_GUID_TO_ID() function returns the container ID, which is a NUMBER value.

If any of the parameters are NULL, CON_GUID_TO_ID() will return NULL.

Oracle CON_GUID_TO_ID() Examples

Here are some examples that demonstrate the usage of the Oracle CON_GUID_TO_ID() function.

Basic Usage

You can query all container GUIDs and container IDs from the V$CONTAINERS view, as in the following statement:

SELECT
    CON_ID, GUID
FROM v$containers;

Output:

   CON_ID GUID
_________ ___________________________________
        1 2DB8B52CFBA74041AD04ABD6ED45B927
        2 0F30DFDA4EAC43869B66720C91B0ACE7
        3 8EDD17AF1CE24DF4889C592A60374D90

If you need to get the container ID for the container GUID 0F30DFDA4EAC43869B66720C91B0ACE7, use the CON_GUID_TO_ID() function:

SELECT
    CON_GUID_TO_ID(HEXTORAW('0F30DFDA4EAC43869B66720C91B0ACE7'))
FROM dual;

Output:

   CON_GUID_TO_ID(HEXTORAW('0F30DFDA4EAC43869B66720C91B0ACE7'))
_______________________________________________________________
                                                              2

NULL Parameters

If any of the parameters are NULL, CON_GUID_TO_ID() will return NULL.

SET NULL 'NULL';
SELECT
    CON_GUID_TO_ID(NULL)
FROM dual;

Output:

   CON_GUID_TO_ID(NULL)
_______________________
                   NULL

In this example, we use the statement SET NULL 'NULL'; to display the NULL value as the string 'NULL'.

Conclusion

Oracle CON_GUID_TO_ID() is a built-in function that returns the container ID based on the container GUID.