开发者

Oracle type compare

Oracle & objects:

I have a table that contain more than one type of object (by using inheritance),but i want to know the actual type of each (using loop and ?). Is there a functi开发者_Go百科on like isInstanceOf() here?

plz provide an example

Thanks in Advance


What you want is the OF TYPE clause.



CREATE OR REPLACE TYPE TEST_OBJ AS OBJECT (
  field1  VARCHAR2(20),
  field2  NUMBER(10)
);

Then you can use the SYS.ANYDATA type.


DECLARE
   t_test_obj TEST_OBJ;
   v_anydata SYS.ANYDATA; 
BEGIN
    t_test_obj := TEST_OBJ('ABC',123);
    v_anydata := SYS.ANYDATA.ConvertObject(t_test_obj);
    DBMS_OUTPUT.PUT_LINE('OBJECT TYPE IS : '||v_anydata.GetTypeName());
END;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜