select from inherited object columns : Type Inheritance « Object Oriented « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
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
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 Tutorial » Object Oriented » Type Inheritance 
32. 5. 5. select from inherited object columns
SQL>
SQL>
SQL> CREATE Or Replace TYPE AddressType AS OBJECT (
  2    street VARCHAR2(15),
  3    city   VARCHAR2(15),
  4    state  CHAR(2),
  5    zip    VARCHAR2(5)
  6  )
  7  /

Type created.

SQL>
SQL> CREATE Or Replace TYPE PersonType AS OBJECT (
  2    id         NUMBER,
  3    first_name VARCHAR2(10),
  4    last_name  VARCHAR2(10),
  5    dob        DATE,
  6    phone      VARCHAR2(12),
  7    address    AddressType
  8  NOT FINAL;
  9  /

Type created.

SQL>
SQL>
SQL> CREATE Or replace TYPE business_PersonType UNDER PersonType (
  2    title   VARCHAR2(20),
  3    company VARCHAR2(20)
  4  )
  5  /

Type created.

SQL>
SQL> CREATE TABLE object_business_customers OF business_PersonType
  2  /

Table created.

SQL>
SQL>
SQL> INSERT INTO object_business_customers VALUES (
  2    business_PersonType(1'John', 'Brown', '01-FEB-1933', '800-555-3333',
  3      AddressType('2 Ave', 'town', 'MA', '12345'),'Manager', 'XYZ Corp')
  4  );

row created.

SQL>
SQL>
SQL> SELECT FROM object_business_customers;

 ID FIRST_NAME           LAST_NAME            DOB       PHONE
--- -------------------- -------------------- --------- ------------
ADDRESS(STREET, CITY, STATE, ZIP)
--------------------------------------------------------------------
TITLE                COMPANY
-------------------- --------------------
  John                 Brown                01-FEB-33 800-555-3333
ADDRESSTYPE('2 Ave', 'town', 'MA', '12345')
Manager              XYZ Corp


SQL>
SQL>
SQL> drop table object_business_customers;

Table dropped.

SQL>
SQL>
SQL> drop type business_PersonType;

Type dropped.

SQL>
SQL> drop type persontype;

Type dropped.

SQL>
SQL> drop type addresstype;

Type dropped.

SQL>
SQL>
32. 5. Type Inheritance
32. 5. 1. Type Inheritance
32. 5. 2. The NOT FINAL clause indicates that object can be inherited from when defining another type.
32. 5. 3. NOT FINAL clause
32. 5. 4. Insert data into table with inheritecd columns
32. 5. 5. select from inherited object columns
32. 5. 6. NOT INSTANTIABLE Object Types
32. 5. 7. Query table with sub type column
32. 5. 8. Insert into table with sub type column
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.