Oracle Advance Queue-有效负载类型问题(嵌套对象类型)

时间:2018-01-07 00:25:01

标签: oracle object plsql user-defined-types oracle-aq

我正在尝试在Oracle中创建Advance Queue表。 我为Personts的Assets(如Car,Bike,house)创建了一个对象类型和表类型,为Person创建了另一个对象类型(具有列名和资产表类型)。

我需要存储有嵌套细节的有效负载(Header和嵌套细节)。但是,我在执行CREATE_QUEUE_TABLE时遇到错误:

ORA-22913: must specify table name for nested table column or attribute
ORA-06512: at “SYS.DBMS_AQADM”, line 81
ORA-06512: at line 2

执行阻止:

begin
    DBMS_AQADM.CREATE_QUEUE_TABLE (
        queue_table => 'sau_q_tab'
       , queue_payload_type => 'sau_person_o_type'
    );
end;

对象类型详细信息:

CREATE OR REPLACE TYPE sau_asset_o_type as object (
    asset_id number,
    asset_name varchar2(30),
    CONSTRUCTOR FUNCTION sau_asset_o_type
        RETURN SELF AS RESULT
);
/

CREATE OR REPLACE TYPE sau_asset_t_type AS TABLE OF sau_asset_o_type;
/

CREATE OR REPLACE TYPE sau_person_o_type as object (
    person_name varchar2(30),
    person_assets sau_asset_t_type,
    CONSTRUCTOR FUNCTION sau_person_o_type /*nested table type*/
         RETURN SELF AS RESULT);
/

CREATE OR REPLACE TYPE BODY sau_person_o_type IS
    CONSTRUCTOR FUNCTION sau_person_o_type
    RETURN SELF AS RESULT IS
    BEGIN
        RETURN;
    END;
END;
/

CREATE OR REPLACE TYPE BODY sau_asset_o_type IS
    CONSTRUCTOR FUNCTION sau_asset_o_type
    RETURN SELF AS RESULT IS
    BEGIN
        RETURN;
    END;
END;
/

1 个答案:

答案 0 :(得分:0)

您需要使用storage_clause参数指定嵌套表的名称。

由于队列表中的相应列被称为user_data,我们需要使用此列名:

BEGIN
    DBMS_AQADM.CREATE_QUEUE_TABLE (
        queue_table => 'sau_q_tab'
       , queue_payload_type => 'sau_person_o_type'
       , storage_clause     => 'NESTED TABLE user_data.person_assets STORE AS sau_q_nested'
    );
END;