Oracle CON_NAME_TO_ID() Function
Oracle CON_NAME_TO_ID() is a built-in function that returns the container ID based on the container name.
Oracle CON_NAME_TO_ID() Syntax
Here is the syntax for the Oracle CON_NAME_TO_ID() function:
CON_NAME_TO_ID(container_name)
Parameters
container_name-
Required. The container name. It can be a string or any type that can be resolved to a string.
Return Value
The Oracle CON_NAME_TO_ID() function returns the container ID, which is a NUMBER value.
If any of the parameters is NULL, CON_NAME_TO_ID() returns NULL.
Oracle CON_NAME_TO_ID() Examples
Here are a few examples that demonstrate the usage of the Oracle CON_NAME_TO_ID() function.
Basic Usage
You can query all container names and container IDs from the V$CONTAINERS view, as shown in the following statement:
SELECT
CON_ID, NAME
FROM v$containers;
Output:
CON_ID NAME
_________ ___________
1 CDB$ROOT
2 PDB$SEED
3 XEPDB1If you need to get the container ID for the container name XEPDB1, use the CON_NAME_TO_ID() function:
SELECT
CON_NAME_TO_ID('XEPDB1')
FROM dual;
Output:
CON_NAME_TO_ID('XEPDB1')
___________________________
3NULL Parameter
If any of the parameters is NULL, CON_NAME_TO_ID() returns NULL.
SET NULL 'NULL';
SELECT
CON_NAME_TO_ID(NULL)
FROM dual;
Output:
CON_NAME_TO_ID(NULL)
_______________________
NULLIn this example, we use the statement SET NULL 'NULL'; to display the NULL value as the string 'NULL'.
Conclusion
Oracle CON_NAME_TO_ID() is a built-in function that returns the container ID based on the container name.