Cursor of user-defined objects : Cursor « Object Oriented Database « Oracle PL / SQL






Cursor of user-defined objects

 
SQL>
SQL> CREATE TABLE MyTable (
  2    f1 NUMBER,
  3    f2 VARCHAR2(50)
  4  );

Table created.

SQL>
SQL> CREATE or replace TYPE objType AS OBJECT (
  2    f1 NUMBER,
  3    f2 VARCHAR2(50)
  4  );
  5  /

Type created.

SQL> show errors
No errors.
SQL>
SQL> CREATE TABLE obj_tab OF objType;

Table created.

SQL>
SQL> DECLARE
  2
  3    CURSOR c_AllRows IS
  4      SELECT * FROM obj_tab;
  5  BEGIN
  6    FOR v_Row IN c_AllRows LOOP
  7      DBMS_OUTPUT.PUT_LINE(v_Row.f1 || ' ' || v_Row.f2);
  8    END LOOP;
  9  END;
 10  /

PL/SQL procedure successfully completed.

SQL>
SQL> DROP TABLE MyTable;

Table dropped.

SQL> DROP TABLE obj_tab;

Table dropped.

SQL>

 








Related examples in the same category

1.Cursor for user-defined object type