可以使用SQL Multiset Conditions来比较嵌套表和测试它们的属性。
|
DECLARE TYPE nested_typ IS TABLE OF NUMBER; nt1 nested_typ := nested_typ(1,2,3); nt2 nested_typ := nested_typ(3,2,1); nt3 nested_typ := nested_typ(2,3,1,3); nt4 nested_typ := nested_typ(1,2,4); PROCEDURE testify (truth BOOLEAN := NULL, quantity NUMBER := NULL) IS BEGIN IF truth IS NOT NULL THEN DBMS_OUTPUT.PUT_LINE ( CASE truth WHEN TRUE THEN 'True' WHEN FALSE THEN 'False' END); END IF; IF quantity IS NOT NULL THEN DBMS_OUTPUT.PUT_LINE(quantity); END IF; END; BEGIN testify(truth => (nt1 IN (nt2, nt3, nt4))); -- 条件 testify(truth => (nt1 SUBMULTISET OF nt3)); -- 条件 testify(truth => (nt1 NOT SUBMULTISET OF nt4)); -- 条件 --测试集合成员的个数 testify(truth => (4 MEMBER OF nt1)); -- 条件 testify(truth => (nt3 IS A SET)); -- 条件 testify(truth => (nt3 IS NOT A SET)); -- 条件 testify(truth => (nt1 IS EMPTY)); -- 条件 -- cardinality返回嵌套表中元素的个数 testify(quantity => (CARDINALITY(nt3))); -- 函数 testify(quantity => (CARDINALITY(SET(nt3)))); -- 2个函数
END;
|
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/17013648/viewspace-1107995/ ,如需转载,请注明出处,否则将追究法律责任。