Download Oracle Database PL/SQL User's Guide and Reference

Transcript
Qualifying References to Object Attributes and Methods
References to Row Expressions
Row expressions must resolve as references to table aliases. You can pass row
expressions to operators REF and VALUE, and you can use row expressions in the SET
clause of an UPDATE statement. Some examples follow:
CREATE TYPE t1 AS OBJECT (x number);
/
CREATE TABLE ot1 OF t1;
BEGIN
-- following inserts are allowed without an alias
-- because there is no column list
INSERT INTO ot1 VALUES ( t1(10) );
INSERT INTO ot1 VALUES ( 20 );
INSERT INTO ot1 VALUES ( 30 );
END;
/
BEGIN
UPDATE ot1 SET VALUE(ot1.x) = t1(20) WHERE VALUE(ot1.x) = t1(10); -- not allowed
END;
/
BEGIN -- following allowed with table alias
UPDATE ot1 o SET o = (t1(20)) WHERE o.x = 10;
END;
/
DECLARE
n_ref REF t1;
BEGIN -- following allowed with table alias
SELECT REF(o) INTO n_ref FROM ot1 o WHERE VALUE(o) = t1(30);
END;
/
DECLARE
n t1;
BEGIN -- following allowed with table alias
SELECT VALUE(o) INTO n FROM ot1 o WHERE VALUE(o) = t1(30);
END;
/
DECLARE
n NUMBER;
BEGIN -- following allowed with table alias
SELECT o.x INTO n FROM ot1 o WHERE o.x = 30;
END;
/
BEGIN
DELETE FROM ot1 WHERE VALUE(ot1) = (t1(10)); -- not allowed
END;
/
BEGIN -- folowing allowed with table alias
DELETE FROM ot1 o WHERE VALUE(o) = (t1(20));
END;
/
How PL/SQL Resolves Identifier Names B-7