Quick Search:
 
 Oracle PL/SQL REF Data Type      [Return To Index] Jump to:  

Term: REF

Definition:
In Oracle PL/SQL, REF data types are pointers that uniquely identify a piece of data as an object. A reference can be established between an existent valid object and a table or type attribute using the REF pointer data type. An attribute referring to a nonexistent object leads to "dangling" situation. Note that a NULL object reference is different from a Dangling Reference.

To insert data into a ref column, the REF function is used to get an object instance reference.

Example Syntax:

[ATTRIBUTE | COLUMN] REF [OBJECT TYPE]


Example Usage:

The example code below shows the declaration of the REF attribute in table REFTAB. It points to TYPE_REFT object instance. Note the usage of REF as a function and the reference to an object instance.

CREATE OR REPLACE TYPE TYP_REFT AS OBJECT 
(A NUMBER,
B NUMBER);
/

Type created.

CREATE TABLE REFTT OF TYP_REFT;

Table created.

CREATE TABLE REFTAB
(ID REF TYP_REFT);

Table created.

INSERT INTO REFTT VALUES (1,2);

1 row created.

INSERT INTO REFTAB
SELECT REF(T) FROM REFTT T

1 row created.

SELECT * FROM REFTAB;

ID
--------------------------------------------------------------------------------
00002202086F2A5BC83EC7440E97984B2C9EA9D9FEB2393991A58C4229897D0F775122F006



Related Links:

Related Code Snippets:
  • REFTOHEX - REFTOHEX converts argument expr to a character value containing its hexadecimal equival...
 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org