Manipulating objects in pl sql, PL-SQL Programming

Manipulating Objects:

You can use an object type in the CREATE TABLE statement to indicate the datatype of a column. When the table is created once, you can use the SQL statements to insert an object, call its methods, select its attributes, & update its state.

In the SQL*Plus script shown below, the INSERT statement calls the constructor for the object type Rational, and then inserts the resultant object. The SELECT statements retrieve the value of the attribute num. The UPDATE declaration calls member method reciprocal, that returns a Rational value after exchanging the attributes num and den. Note that the table alias is needed whenever you reference an attribute or method.

CREATE TABLE numbers (rn Rational, ...)

/

INSERT INTO numbers (rn) VALUES (Rational(3, 62)) -- inserts 3/62

/

SELECT n.rn.num INTO my_num FROM numbers n ... -- returns 3

/

UPDATE numbers n SET n.rn = n.rn.reciprocal ... -- yields 62/3

/

When you instantiate an object in this way, it has no individuality outside the database table. Though, the object type exists separately of any table, and can be used to create objects in the other ways.

In the later illustration, you build a table which stores objects of the type Rational in its rows. These tables, having rows of objects, are known as the object tables. Each column in a row corresponds to the attribute of the object type. The Rows can have various column values.

CREATE TABLE rational_nums OF Rational;

Each row in the object table has an object identifier that uniquely identifies the object stored in that row and serve as a reference to the object.

Posted Date: 10/6/2012 8:16:18 AM | Location : United States







Related Discussions:- Manipulating objects in pl sql, Assignment Help, Ask Question on Manipulating objects in pl sql, Get Answer, Expert's Help, Manipulating objects in pl sql Discussions

Write discussion on Manipulating objects in pl sql
Your posts are moderated
Related Questions
Aggregate Assignment The %ROWTYPE declaration cannot include an initialization clause. Though, there are two ways to assign values to all fields in a record at once. At First, t

Relational Operators The relational operators permit you to compare randomly complex expressions. The list below provides the meaning of each operator:

%TYPE: This attribute gives the datatype of a formerly declared collection, cursor variable, object, field, record, database column, or variable. Datatype: This is simply

Majority of Differences among 9i, 10G, 11G :- These are some combine feature which has differences among others. Automatic Workload Repository (AWR) Drop database' s

SQL Pseudocolumns The PL/SQL recognizes the following SQL pseudocolumns, that returns the specific data items: LEVEL, NEXTVAL, CURRVAL, ROWID, & ROWNUM. The Pseudocolumns are n

We are seeking a freelance consultant that is familiar with Appgen applications. We require exporting all our data into a format appropriate for importing into SAP Business One. Pl

i NEED TO CREATE 3 guiS IN pl/sql sERVER PAGE FORM

DBMS_OUTPUT: The Package DBMS_OUTPUT enables you to display output from the PL/SQL subprograms and blocks, that makes it easier to test and debug them. The procedure put_ line

Predicate - SQL Consider the declarative sentence-a proposition-that is used to introduce this topic:  "Student S1, named Anne, is enrolled on course C1." Recall that th

1. a. Write a trigger that fires when a part's price is updated. The trigger will write a record into a table called PriceUpdates. The record should contain the information of