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

Home
Oracle PL / SQL
1.Aggregate Functions
2.Analytical Functions
3.Char Functions
4.Constraints
5.Conversion Functions
6.Cursor
7.Data Type
8.Date Timezone
9.Hierarchical Query
10.Index
11.Insert Delete Update
12.Large Objects
13.Numeric Math Functions
14.Object Oriented Database
15.PL SQL
16.Regular Expressions
17.Report Column Page
18.Result Set
19.Select Query
20.Sequence
21.SQL Plus
22.Stored Procedure Function
23.Subquery
24.System Packages
25.System Tables Views
26.Table
27.Table Joins
28.Trigger
29.User Previliege
30.View
31.XML
Oracle PL / SQL » Object Oriented Database » Cursor 
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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.