Inserting a row into an object table using constructor : Constructor « 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>
SQL> INSERT INTO object_products VALUES (
  2    ProductType(1, 'AAA', 'BBB', 3.95, 10)
  3  );

1 row created.

SQL>
SQL> select * from object_products;

 ID NAME            DESCRIPTION                 PRICE DAYS_VALID
--- --------------- ---------------------- ---------- ----------
  1 AAA             BBB                          3.95         10

SQL>
SQL> drop table object_products;

Table dropped.

SQL>
SQL>








32.2.Constructor
32.2.1.Inserting a row into an object table using constructor
32.2.2.Using the default constructor (the name of the class)
32.2.3.User-Defined Constructors
32.2.4.Construct user-defined type with subquery
32.2.5.Use constructor to create new objects
32.2.6.Demonstrates object initialization.