SQL>
SQL> CREATE TABLE rel_tab (
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>
SQL> DECLARE
2 v_Row rel_tab%ROWTYPE;
3 CURSOR c_AllRows IS
4 SELECT * FROM rel_tab;
5 BEGIN
6 OPEN c_AllRows;
7 LOOP
8 FETCH c_AllRows INTO v_Row;
9 EXIT WHEN c_AllRows%NOTFOUND;
10 DBMS_OUTPUT.PUT_LINE(v_Row.f1 || ' ' || v_Row.f2);
11 END LOOP;
12 CLOSE c_AllRows;
13 END;
14 /
PL/SQL procedure successfully completed.
SQL>
SQL> drop table rel_tab;
Table dropped.
SQL> drop table obj_tab;
Table dropped.
SQL>
|