This script demonstrates attribute chaining. : Attribute « Object Oriented Database « Oracle PL / SQL

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
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL / SQL » Object Oriented Database » Attribute 
This script demonstrates attribute chaining.
   

SQL>
SQL> CREATE OR REPLACE TYPE addressType AS OBJECT (
  2     address1   VARCHAR2 (30 CHAR),
  3     address2   VARCHAR2 (30 CHAR),
  4     city       VARCHAR2 (30 CHAR),
  5     state      CHAR (CHAR)
  6  )
  7  INSTANTIABLE FINAL;
  8  /

Type created.

SQL>
SQL> CREATE OR REPLACE TYPE personType AS OBJECT (
  2     fname   VARCHAR2 (20),
  3     lname    VARCHAR2 (20)
  4  )
  5  INSTANTIABLE FINAL;
  6  /


SQL>
SQL> CREATE OR REPLACE TYPE contactType AS OBJECT (
  2     NAME      personType,
  3     address   addressType,
  4     phone     NUMBER (10)
  5  )
  6  INSTANTIABLE FINAL;
  7  /

Type created.

SQL>
SQL> CREATE OR REPLACE TYPE publisher_obj AS OBJECT (
  2     pub_name       VARCHAR2 (30),
  3     contact_info   contactType,
  4     MEMBER PROCEDURE show_contact
  5  )
  6  INSTANTIABLE FINAL;
  7  /

SP2-0816: Type created with compilation warnings

SQL>
SQL> CREATE OR REPLACE TYPE BODY publisher_obj
  2  AS
  3     MEMBER PROCEDURE show_contact
  4     IS
  5     BEGIN
  6        DBMS_OUTPUT.put_line (SELF.pub_name);
  7        DBMS_OUTPUT.put_line (SELF.contact_info.NAME.fname|| ' '|| SELF.contact_info.NAME.lname);
  8        DBMS_OUTPUT.put_line (SELF.contact_info.address.address1);
  9        DBMS_OUTPUT.put_line (SELF.contact_info.address.city);
 10        DBMS_OUTPUT.put_line (SELF.contact_info.address.state);
 11        DBMS_OUTPUT.put_line (SELF.contact_info.phone);
 12        RETURN;
 13     END show_contact;
 14  END;
 15  /

SP2-0818: Type Body created with compilation warnings

SQL>
SQL>  SET SERVEROUTPUT ON SIZE 1000000
SQL>  DECLARE
  2      v_person      personType    := personType ('R''A');
  3      v_address     addressType   := addressType ('1 Way', NULL, 'Springs', 'CO');
  4      v_contact     contactType := contactType (v_person, v_address, 5);
  5      v_publisher   publisher_obj := publisher_obj ('Press', v_contact);
  6   BEGIN
  7     v_publisher.show_contact;
  8   END;
  9   /
Press
R A
Way
Springs
CO
5

PL/SQL procedure successfully completed.

SQL>

   
    
    
  
Related examples in the same category
1. Reference type attribute through column name
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.