Value() treats the row as an actual object and returns the attributes for the object within a constructor for the object type.
The VALUE() function accepts a parameter containing a table alias
SQL> CREATE Or Replace TYPE ProductType AS OBJECT (
2 id NUMBER,
3 name VARCHAR2(15),
4 description VARCHAR2(22),
5 price NUMBER(5, 2),
6 days_valid NUMBER
7 )
8 /
Type created.
SQL>
SQL> CREATE TABLE object_products OF ProductType
2 /
Table created.
SQL>
SQL> INSERT INTO object_products (
2 id, name, description, price, days_valid
3 ) VALUES (
4 2, 'AAA', 'BBB', 2.99, 5
5 );
1 row created.
SQL>
SQL> select * from object_products;
ID NAME DESCRIPTION PRICE DAYS_VALID
--- --------------- ---------------------- ---------- ----------
2 AAA BBB 2.99 5
SQL>
SQL> SELECT VALUE(op)
2 FROM object_products op;
VALUE(OP)(ID, NAME, DESCRIPTION, PRICE, DAYS_VALID)
---------------------------------------------------
PRODUCTTYPE(2, 'AAA', 'BBB', 2.99, 5)
SQL>
SQL>
SQL> drop table object_products;
Table dropped.
SQL>
32.17.VALUE Function |
| 32.17.1. | Use the built-in Oracle database VALUE() function to select a row from an object table |
| 32.17.2. | VALUE operator |