赋予参考变量值oracle

hHey,我想在node_ty的方法中设置赋值的值,但是我得到的错误是不允许通过Ref变量导航或者我想赋值的类型不正确。但是我得到的错误是不允许通过Ref变量导航,或者我想赋值的类型不正确。所以我真的不知道该怎么做。你能帮我解决这个问题吗?

CREATE OR REPLACE TYPE property_ty AS OBJECT(
name VARCHAR2(100)
);
/

CREATE OR REPLACE TYPE assignment_ty AS OBJECT(
value VARCHAR2(100),
property REF property_ty
);
/

CREATE OR REPLACE TYPE property_tty AS TABLE OF property_ty;
/


CREATE OR REPLACE TYPE node_ty AS OBJECT(
x NUMBER,
y NUMBER,
assignment REF assignment_ty,
property property_tty,
MEMBER PROCEDURE set_assignment (name VARCHAR2, value VARCHAR2)
);
/
CREATE OR REPLACE TYPE BODY node_ty AS
    MEMBER PROCEDURE set_assignment (name VARCHAR2, value VARCHAR2) AS
    prop_not_added EXCEPTION;
    prop_exists BOOLEAN := FALSE;
    assig_test assignment_ty;
    prop property_ty;
    BEGIN
        FOR i IN 1..self.property.COUNT
        LOOP
            IF property(i).name = name THEN
               prop.name :=name;
               assig_test.value :=value;
               assig_test.property := prop;
               assignment := assig_test;
               prop_exists := TRUE;

            END IF;
        END LOOP;

        IF prop_exists = FALSE THEN
            RAISE prop_not_added;
        END IF;

        EXCEPTION
            WHEN prop_not_added THEN
            DBMS_OUTPUT.PUT_LINE('Property cannot be set');
    END;
END;
/

解决方案:

你必须创建必要的设置,然后从设置中查询数据.我只给出了与你不同的设置,其余的你可以保持与你的设置相同。

   create table t00 of property_ty;
   insert into t00 values('san');

   create table t0 of assignment_ty;
   insert into t0 select 'xxx',REF(p) from t00 p;

   CREATE OR REPLACE TYPE node_ty AS OBJECT(
    x NUMBER,
    y NUMBER,
    assignment REF assignment_ty,
    property property_tty,
    MEMBER PROCEDURE set_assignment (p_name VARCHAR2, p_value VARCHAR2)
    );

   create or replace TYPE BODY node_ty AS
MEMBER PROCEDURE set_assignment (p_name  VARCHAR2, p_value  VARCHAR2) AS
prop_not_added EXCEPTION;
prop_exists BOOLEAN := FALSE;
assig_test REF  assignment_ty;
prop1 property_ty;
prop REF property_ty;
BEGIN

    FOR i IN 1..self.property.COUNT
    LOOP
        IF property(i).name = p_name THEN

         SELECT REF(a) INTO assignment FROM t0 a,t00 b where a.value=p_value and b.name=p_name
         and ref(b)=property;

           prop_exists := TRUE;

        END IF;
    END LOOP;

    IF prop_exists = FALSE THEN
        RAISE prop_not_added;
    END IF;

    EXCEPTION
        WHEN prop_not_added THEN
        DBMS_OUTPUT.PUT_LINE('Property cannot be set');
END;
END;

给TA打赏
共{{data.count}}人
人已打赏
解决方案

循环选择归属返回一个额外的列?

2022-4-21 16:09:11

解决方案

在Selenium中的单个窗口中改变不同页面之间的驱动焦点

2022-4-21 16:09:13

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索