Oracle
  Home arrow Oracle arrow Database Interaction with PL/SQL: OBJE...
The Best Selling PC Migration Utility.
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
eWeek
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ORACLE

Database Interaction with PL/SQL: OBJECT and OBJECT
By: Jagadish Chatarji
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 20
    2005-06-14

    Table of Contents:
  • Database Interaction with PL/SQL: OBJECT and OBJECT
  • Accessing OBJECT TYPE using PL/SQL
  • Working with column based OBJECTs
  • Accessing column based OBJECTs in PL/SQL

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    CIO Insight
     
    ADVERTISEMENT

    PCmover - $15 Off with Coupon Code CJPH7Q

    Database Interaction with PL/SQL: OBJECT and OBJECT
    (Page 1 of 4 )

    Jagadish Chatarji has been writing about database interactions with Oracle PL/SQL. The last part examined using TABLE, RECORD and NESTED TABLES with PL/SQL. This one now introduces OBJECT TYPE in Oracle, and explains both SQL and PL/SQL ways of working with OBJECTs. This article is the fourth in the series.

    Please note that all the examples in this series have been tested only with Oracle 10g, not with all the previous versions of Oracle.  I suggest you to refer the documentation of respective version you are using if any of the programs failed to execute.

    Introduction to OBJECT TYPE:

    It is worthwhile to introduce the concept of OBJECT here, as we can also work with OBJECTs in PL/SQL pleasantly.  I will not go much into the depth of OOPS with MEMBER methods etc at this moment.  My up-coming articles will look into the depth of OOPS in Oracle 10g.  For now we will just concentrate on minimum basics of OBJECT together with PL/SQL.

    For the time being, just consider OBJECT type as similar to RECORD type in PL/SQL (RECORD was explained in part-2 and part-3 of my articles).  RECORD type works only in PL/SQL.  But OBJECT type gets stored in database and can be used in both SQL and PL/SQL (without redefining it in PL/SQL).

    Let us consider the following example.

    CREATE TYPE t_experience AS OBJECT
    (
                Ename          varchar2(20),
                CompanyName    varchar2(20),
                Position       varchar2(20),
                NoOfYears      number(2)
    );
    /

    The above script just creates only an OBJECT TYPE (not a table).  Remember it is TYPE (which means something like a datatype).  The OBJECT TYPE can be used to create a table based on its definition.

    CREATE TABLE Employees OF t_experience;

    The above statement creates a new table named ‘Employees’ with exactly the same structure of ‘t_experience’.  The following statement inserts a row based on the OBJECT TYPE structure.

    insert into employees values
     
    ('jag','xyz company','software engineer',5);

    I don’t think you would find any difference between above statement and ordinary INSERT, as they work the same way.  Even though the above INSERT is valid, for better readability, it is always suggested to issue the above statement as follows:

    insert into employees values (t_experience('jag','xyz
      company','software engineer',5));

    The only difference is that we are enclosing all the values into the specification of OBJECT TYPE ‘t_experience’.  All the other DML commands (INSERT, UPDATE, DELETE and SELECT) can be issued just like ordinary SQL statements without any difference.

    More Oracle Articles
    More By Jagadish Chatarji


       · Hello guys, this is my article on working with OBJECT and OBJECT TYPE in PL/SQL. You...
     

       

    ORACLE ARTICLES

    - Tuning PL/SQL Code
    - Debugging PL/SQL Code
    - Testing PL/SQL Code
    - Working With PL/SQL Code
    - Conditional Compilation for Oracle Database ...
    - Compile-Time Warnings for Oracle DB 10g
    - Compiling PL/SQL Code for an Oracle Database
    - Troubleshooting PL/SQL Code
    - Managing PL/SQL Code
    - Data Manipulation and More for HTML DB Appli...
    - Oracle Database Fundamentals
    - Adding Processes to HTML DB Applications
    - Adding Computations, Processes, and Validati...
    - Sub-templates and More with Oracle HTML DB
    - Focusing on Templates in Oracle HTML DB

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway