首先了解一下该包中创建的类型
-- array of anydata
TYPE anydata_array IS TABLE OF ANYDATA
INDEX BY BINARY_INTEGER;
-- Lists of database links
TYPE dblink_array IS TABLE OF VARCHAR2(128)
INDEX BY BINARY_INTEGER;
-- Order in which objects should be generated.
TYPE index_table_type IS TABLE OF BINARY_INTEGER
INDEX BY BINARY_INTEGER;
-- List of active instance numbers and instance names
-- Starting index of instance_table is 1;
TYPE instance_record IS RECORD (
inst_number NUMBER,
inst_name VARCHAR2(60));
-- Instance_table is dense.
TYPE instance_table IS TABLE OF instance_record
INDEX BY BINARY_INTEGER;
-- Lists of Long NAME: includes
-- fully qualified attribute names.
TYPE lname_array IS TABLE OF VARCHAR2(4000)
INDEX BY BINARY_INTEGER;
-- Lists of large VARCHAR2s should be stored here
TYPE maxname_array IS TABLE OF VARCHAR2(32767)
INDEX BY BINARY_INTEGER;
-- Lists of NAME
TYPE name_array IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
-- The order in which objects should be
-- generated is returned here for users
TYPE number_array IS TABLE OF NUMBER
INDEX BY BINARY_INTEGER;
-- Lists of "USER"."NAME"."COLUMN"@LINK
TYPE uncl_array IS TABLE OF VARCHAR2(227)
INDEX BY BINARY_INTEGER;
SUBTYPE maxraw IS RAW(32767);
(1)DBMS_UTILITY.active_instances区分集群中活动的实例
参数
dbms_utility.active_instances (
instance_table OUT INSTANCE_TABLE,
instance_count OUT NUMBER);
DECLARE
l_instance_table DBMS_UTILITY.instance_table;
l_instance_count NUMBER;
BEGIN
DBMS_UTILITY.active_instances (instance_table => l_instance_table,
instance_count => l_instance_count);
IF l_instance_count > 0 THEN
FOR i IN 1 .. l_instance_count LOOP
DBMS_OUTPUT.put_line(l_instance_table(i).inst_number || ' = ' || l_instance_table(i).inst_name);
END LOOP;
END IF;
END;
(2)DBMS_UTILITY.current_instance返回当前实例的数目
参数
dbms_utility.current_instance RETURN NUMBER;
SELECT DBMS_UTILITY.current_instance
FROM dual;
(3)DBMS_UTILITY.is_cluster_database判断该数据库是否为集群数据库
参数
dbms_utility.is_cluster_database RETURN BOOLEAN;
BEGIN
IF DBMS_UTILITY.is_cluster_database THEN
DBMS_OUTPUT.put_line('Clustered');
ELSE
DBMS_OUTPUT.put_line('Not Clustered');
END IF;
END;
(4)DBMS_UTILITY.db_version返回数据库的版本信息
参数
dbms_utility.db_version (
version OUT VARCHAR2,
compatibility OUT VARCHAR2);
SET SERVEROUTPUT ON
DECLARE
l_version VARCHAR2(100);
l_compatibility VARCHAR2(100);
BEGIN
DBMS_UTILITY.db_version (version => l_version,
compatibility => l_compatibility);
DBMS_OUTPUT.put_line('Version: ' || l_version || ' Compatibility: ' || l_compatibility);
END;
/
(5)dbms_utility.table_to_comma数组类型转化为文本类型
参数
dbms_utility.table_to_comma (
tab IN UNCL_ARRAY,
tablen OUT BINARY_INTEGER,
list OUT VARCHAR2);
DECLARE
x dbms_utility.uncl_array;
y BINARY_INTEGER;
z VARCHAR2(4000);
i int:=1;
BEGIN
for r in (select ename from emp ) loop
x(i):=r.ename;
i:=i+1;
end loop;
dbms_utility.table_to_comma(x, y, z);
dbms_output.put_line('Array Size: ' || TO_CHAR(y));
dbms_output.put_line('List: ' || z);
END;
/
(6)dbms_utility.comma_to_table
研究中