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
Parameter and Keyword Description: procedure_name The user-defined procedure is declared by this construct. parameter_name: This identifies the formal parameter t

UNNEST operator in SQL The inverse operator of GROUP is UNGROUP. SQL has an operator, UNNEST, that can be used for similar purposes, but its method of invocation is somewhat p

Cursors   To execute the multi-row query, the Oracle opens an unnamed work region which stores the processing information. The cursor names the work region, access the informa

EXIT Statement   You can use the EXIT statement to exit a loop. The EXIT statement has 2 forms: the conditional EXIT WHEN and the unconditional EXIT. With the either form, you

Application to Export Excel Data to MSSQL Server table I am having a table available in excel format and features the subsequent: - Some text is in Arabic (e.g. UTF-8 encodin

Organi c Evolution Evolution is a slow continuous, irreversible and natural process of change to give rise to advance and diverse forms of life i.e. formation of new specie

Multiset types - SQL An SQL multiset is what in mathematics is also known as a bag-something like a set except that the same element can appear more than once. The body of an

Assignment Source Not a Literal - Variable Syntax: SET SN = SID (SUBSTRING (SN.C FROM 1 FOR 1)||'5');

Package Body: The package specification is implemented by the package body. That is, the package body has the definition of every cursor and the subprogram declared in the pac

Parameter Aliasing   To optimize the subprogram call, the PL/SQL compiler can decide between the two techniques of the parameter passing. With the by-value techniques, the v