Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Instead of trigger question

Instead of trigger question

From: Emad-ud-deen Richard Leiman & Eva Fithria Leiman <leimam_at_sbcglobal.net>
Date: Wed, 25 Feb 2004 17:46:36 GMT
Message-ID: <0c5%b.27903$d21.240@newssvr16.news.prodigy.com>


Dear group,

Hi.

I am experimenting with instead of triggers. In the code I wish to insert into a table that contains abstract data types. The abstract data types are object types are address, and phone_type.

The phone_type object type looks like this: CREATE OR REPLACE TYPE phone_type AS OBJECT (

   phone_1                       NUMBER (8, 0),
   phone_2                       NUMBER (8, 0),
   phone_3                       NUMBER (8, 0)
)
/

The address object type looks like this: CREATE OR REPLACE TYPE address AS OBJECT (

   NAME                          VARCHAR2 (26),
   fathername                     VARCHAR2 (25),
   address                          VARCHAR2 (25),
   phone                            oracle_objects.phone_type
);
/

As it is now I can compile the trigger with this code:

CREATE OR REPLACE TRIGGER oracle_objects.student_instead_of_trigger

   INSTEAD OF INSERT
   ON oracle_objects.full_student_view
   REFERENCING NEW AS NEW OLD AS OLD
   FOR EACH ROW
BEGIN
   DBMS_OUTPUT.put_line ('You are in the instead of trigger now.');

   INSERT INTO student

                           (student_id,
                            student_information
                           )
        VALUES (:new.student_id,
                address ('Emad-ud-deen',
                              'Leiman',
                              '123 Testing Street',
                              phone_type (3213452,
                                                  9999999,
                                                  3333333
                                                 )
                             )
                );

END;
/

My question is: How do I change this code so :new will be ok inside the address, and phone_type object types?

I tried this code but Oracle returns this error: PLS-00049: bad bind variable 'NEW.NAME'

CREATE OR REPLACE TRIGGER oracle_objects.student_instead_of_trigger

   INSTEAD OF INSERT
   ON oracle_objects.full_student_view
   REFERENCING NEW AS NEW OLD AS OLD
   FOR EACH ROW
BEGIN
   DBMS_OUTPUT.put_line ('You are in the instead of trigger now.');

   INSERT INTO student

                           (student_id,
                            student_information
                           )
        VALUES (:new.student_id,
                address (:new.name,
                              :new.father.name,
                              :new.address,
                              phone_type (:new.phone_1,
                                                  :new.phone_2,
                                                  :new.phone_3
                                                 )
                              )
               );

END;
/

Truly,
Emad Received on Wed Feb 25 2004 - 11:46:36 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US