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
Extension and AND in SQL The theory book gives the following simple example of relational extension in Tutorial D: EXTEND IS_CALLED ADD ( FirstLetter ( Name ) AS Initial )

Parameter and Keyword Description: package_name: This construct identifies the package. AUTHID Clause: This determine whether all the packaged subprograms impleme

Control Structures The Control structures are the most important PL/SQL extension to the SQL. Not only does PL/SQL let you manipulate Oracle data, it lets you process the data

Use the NOCOPY Compiler Hint By default, the OUT and IN OUT parameters are passed by the value i.e. the value of an IN OUT actual parameter is copied into the corresponding fo

How Calls Are Resolved? The figure shows that how the PL/SQL compiler resolves the subprogram calls. When the compiler encounters the procedure or function call, it tries to di

Example of GROUPBY Operator Example: How many students sat each exam, using GROUP BY, NATURAL LEFT JOIN, and COALESCE SELECT CourseId, COALESCE (n, 0) AS n FROM COURS

FETCH Statement The FETCH statement retrieve rows of data one at a time from the result set of the multi-row query. The data is stored in fields or variables which correspond t

Advantages of Subprograms The Subprograms give extensibility; that is, tailor the PL/SQL language to suit your requirements. For illustration, if you require a procedure which

EXECUTE Privilege To call an invoker-rights routine straightforwardly, the users should have the EXECUTE privilege on that routine. By yielding the privilege, you permit a user

Parameter Modes: You do not require to specify a parameter mode for the input bind arguments (those used, for illustration, in the WHERE clause) as the mode defaults to IN. Th