Using operator ref - manipulating objects pl sql, PL-SQL Programming

Using Operator REF:

You can retrieve refs by using the operator REF that, like VALUE, takes as its argument a correlation variable. In the illustration below, you retrieve one or more refs to the Person objects, then insert the refs into the table person_refs:

BEGIN

INSERT INTO person_refs

SELECT REF(p) FROM persons p

WHERE p.last_name LIKE '%Smith';

In the later illustration, you retrieve a ref and attribute at similar time:

DECLARE

p_ref REF Person;

taxpayer_id VARCHAR2(9);

BEGIN

SELECT REF(p), p.ss_number INTO p_ref, taxpayer_id

FROM persons p

WHERE p.last_name = 'Parker'; -- must return one row

...

END;

In the final illustration, you update the attributes of a Person object:

DECLARE

p_ref REF Person;

my_last_name VARCHAR2(15);

...

BEGIN

...

SELECT REF(p) INTO p_ref FROM persons p

WHERE p.last_name = my_last_name;

UPDATE persons p

SET p = Person('Jill', 'Anders', '11-NOV-67', ...)

WHERE REF(p) = p_ref;

END;

Posted Date: 10/6/2012 8:20:37 AM | Location : United States







Related Discussions:- Using operator ref - manipulating objects pl sql, Assignment Help, Ask Question on Using operator ref - manipulating objects pl sql, Get Answer, Expert's Help, Using operator ref - manipulating objects pl sql Discussions

Write discussion on Using operator ref - manipulating objects pl sql
Your posts are moderated
Related Questions
Transaction Visibility As the figure shows, the changes made by an autonomous transaction become visible to another transaction whenever the autonomous transaction commits. Th

heap sort program in pl/sql

Advantages of Exceptions Using the exceptions for the error handling has many benefits. Without an exception handling, every time you issue a command, you should ensure for th

Defining REF CURSOR Types To make cursor variables, you take 2 steps. At first, you define a REF CURSOR type, and then declare the cursor variables of that type. You can defin

Parameter and Keyword Description: collection_name: This keyword identifies the index-by table, nested table, or varray formerly declared within the present scope. cu

Using the BULK COLLECT Clause The keywords BULK COLLECT specify the SQL engine to bulk-bind output collections before returning them to the PL/SQL engine. You can use these ke

Literature review

What are 3 good practices of modeling and/or implementing data warehouses?

Using RENAME in combination with JOIN - SQL Example gives pairs of ids of students having the same name, by joining two renamings of IS_CALLED. Example gives an equivalent ex

DBMS_PIPE: The Package DBMS_PIPE allows various sessions to communicate over the named pipes. (A pipe is a region of memory used by one of the process to pass information to