Abd
Abd

Reputation: 426

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 function like isInstanceOf() here?

plz provide an example

Thanks in Advance

Upvotes: 2

Views: 372

Answers (2)

David
David

Reputation: 1315


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;

Upvotes: 0

APC
APC

Reputation: 146349

What you want is the OF TYPE clause.

Upvotes: 3

Related Questions