New DBMS_UTILITY Features
Oracle has added two functions to the DBMS_UTILITY package that allow you to obtain information about the currently connected instance as well as active instances.
CURRENT_INSTANCE: Returning the Instance Number
The CURRENT_INSTANCE function returns the currently connected instance number. Its header is:
FUNCTION DBMS_UTILITY.CURRENT_INSTANCE RETURN NUMBER;
This function returns NULL if the connected instance is unavailable (down).
ACTIVE_INSTANCES: Returning a List of Active Instances
The ACTIVE_INSTANCES procedure returns a list of all of the active instances. Its header is:
PROCEDURE DBMS_UTILITY.ACTIVE_INSTANCES ( instance_table OUT DBMS_UTILITY.instance_table, instance_count OUT NUMBER);
instance_table will contain the returned list, and instance_count is the number of active instances. DBMS_UTILITY.INSTANCE_TABLE is defined as follows:
TYPE DBMS_UTILITY.INSTANCE_RECORD IS RECORD ( inst_number NUMBER, inst_name VARCHAR2(60)); TYPE DBMS_UTILITY.INSTANCE_TABLE IS TABLE OF instance_record INDEX BY BINARY_INTEGER;
This procedure behaves as follows:
- When no instance is available (or the parallel server is not in use), the list is empty.
- The instance_count argument contains the number of active instances, or 0 if none are found.
- The starting index of the instance_table is always 1 and the table is always densely filled. The only defined rows of the table, in other words, are 1 through instance_count.