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
Data Abstraction The Data abstraction extracts the important properties of data while ignoring the not necessary details. Once you design a data structure, you can fail to reme

Using Invoker Rights: By default, the stored procedure executes with the privileges of its definer, not its invoker. These procedures are bound to the schema in which they inh

Project Description: I want a small relational database to be built. I want the database to have the subsequent information tables: Employee Information Document storage

I want to implement heap sort algorithm in pl sql please share the source code for guidance

Consider the schema for FreeChecking Bank, that we designed given below. Translate the given ER schema into SQL CREATE TABLE statements (indicating primary key, unique and foreign

Quantification in SQL To quantify something, as the theory book has it, is to state its quantity, to say how many of it there are. For example, in Tutorial D the expression CO

Use of Table Comparisons - SQL Table comparisons where it is noted that although table expressions cannot be compared, we have TABLE (t) to convert a table expression t into

Updating Objects: To change the attributes of objects in an object table, you can use the UPDATE statement, as the illustration below shows: BEGIN UPDATE persons p SET p

Parameter & Keyword Description: function_name: The user-defined function is identifying by that keyword. parameter_name: This identifies the formal parameter that

Packaging Cursors   You can split a cursor specification from its body for placement in a package. In that way, you can change the cursor body without changing the cursor spec