Selecting Rows from the object Table : Object Table « Object Oriented « Oracle PL/SQL Tutorial






SQL>
SQL>
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> drop table object_products;

Table dropped.

SQL>
SQL>








32.9.Object Table
32.9.1.You can also use an object type to define an entire table, and the table is known as an object table.
32.9.2.Inserting a row into an object table
32.9.3.One-step INSERTs into a Table that Contains Row Objects
32.9.4.INSERT Values into a Table that Contains Row Objects (TCRO)
32.9.5.Insert data just as one would ordinarily do with a common SQL table:
32.9.6.SELECTing Individual Columns in Table that Contains Row Objects
32.9.7.Selecting Rows from the object Table
32.9.8.SELECT from the object-oriented table
32.9.9.Updating a Row in the object Table
32.9.10.UPDATE a Table that Contains Row Objects (TCRO)
32.9.11.Accessing the object table by reference
32.9.12.Create a table based on an Object with methods
32.9.13.Alter table to add a user-defined type column