Demonstrate the use of SYS.AnyData : AnyData « PL SQL Data Types « Oracle PL/SQL Tutorial






SQL>
SQL>
SQL> CREATE OR  REPLACE TYPE facebook AS OBJECT (
  2     name VARCHAR2(30),
  3     height NUMBER
  4  );
  5  /

Type created.

SQL>
SQL> CREATE OR REPLACE TYPE firsttalk AS OBJECT (
  2     name VARCHAR2(30),
  3     length NUMBER
  4  );
  5  /

Type created.

SQL>
SQL> DECLARE
  2     TYPE feature_array IS VARRAY(2) OF SYS.AnyData;
  3     features feature_array;
  4     wf facebook;
  5     rv firsttalk;
  6     ret_val NUMBER;
  7  BEGIN
  8
  9     features := feature_array(
 10                    SYS.AnyData.ConvertObject(facebook('Girl',30)),
 11                    SYS.AnyData.ConvertObject(firsttalk('firsttalk', 85.40))
 12                 );
 13
 14
 15     FOR x IN 1..features.COUNT LOOP
 16         CASE features(x).GetTypeName
 17         WHEN 'GENNICK.facebook' THEN
 18            ret_val := features(x).GetObject(wf);
 19            DBMS_OUTPUT.PUT_LINE('facebook: '|| wf.name || ', Height = ' || wf.height || ' feet.');
 20         WHEN 'GENNICK.firsttalk' THEN
 21            ret_val := features(x).GetObject(rv);
 22            DBMS_OUTPUT.PUT_LINE('firsttalk: '|| rv.name || ', Length = ' || rv.length || ' miles.');
 23         END CASE;
 24     END LOOP;
 25  END;
 26  /
DECLARE
*
ERROR at line 1:
ORA-06592: CASE not found while executing CASE statement
ORA-06512: at line 16


SQL>
SQL>








21.38.AnyData
21.38.1.Demonstrate the use of SYS.AnyData