Oracle CON_UID_TO_ID() Function

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

Oracle CON_UID_TO_ID() Syntax

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

CON_UID_TO_ID(container_uid)

Parameters

container_uid

Required. The container UID. It is a NUMBER value or any value that can be implicitly converted to NUMBER.

Return Value

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

If any of the parameters is NULL, CON_UID_TO_ID() will return NULL.

Oracle CON_UID_TO_ID() Examples

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

Basic Usage

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

SELECT
    CON_ID, UID
FROM v$containers;

Output:

    CON_ID    CON_UID
---------- ----------
         1          1
         2 4054529501
         4 2256797992

If you need to get the container ID corresponding to container UID 2256797992, use the CON_UID_TO_ID() function:

SELECT
    CON_UID_TO_ID(2256797992)
FROM dual;

Output:

   CON_UID_TO_ID(2256797992)
____________________________
                           4

NULL Parameter

If any of the parameters is NULL, CON_UID_TO_ID() will return NULL.

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

Output:

   CON_UID_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_UID_TO_ID() is a built-in function that returns the container ID based on the container UID.