ITPub博客

首页 > 数据库 > Oracle > PLSQL Language Referenc-PL/SQL集合和记录-使用Multiset Conditions比较嵌套表

PLSQL Language Referenc-PL/SQL集合和记录-使用Multiset Conditions比较嵌套表

原创 Oracle 作者:LuiseDalian 时间:2014-03-12 07:19:55 0 删除 编辑

使用Multiset Conditions比较嵌套表

可以使用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/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-02-06

  • 博文量
    1986
  • 访问量
    6043844