Oracle sequence number in an ON-INSERT trigger [message #159645] |
Mon, 20 February 2006 14:59 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
bdrufner
Messages: 42 Registered: August 2005 Location: Home of the Mardi Gras, N...
|
Member |
|
|
Forms 9.2.4 (32 bit), RDBMS 9.2.0
I have a master-detail form. The master data block is based on one table [CLASS] and allows the user to populate the form with "class related" data ( class name, number of class hours, etc.). The detail block is based on another table [SESSION] and allows the user to populate the form with "session related" data (session name, session date, etc.). Typically, but not always, I have several sessions for every class.
I am using an Oracle sequence to populate my primary key (PK CLASS ID) for the CLASS table via an ON-INSERT trigger at the data block level for the CLASS data block. I have set the
property of the FK CLASS ID [SESSION data block] for "copy value from item" equal to the PK CLASS ID [CLASS data block].
When the user updates the form, both ON-INSERT triggers fire as typically the user is adding both CLASS and SESSION data. I have attached a partial copy of each trigger.
ON-INSERT trigger for CLASS data block:
begin
insert into hrt_class(pk_class_id, fk_class_location_id, fk_course_id ... )
values(hrt_master_detail_seq.nextval, :db_hrt_class.fk_class_location_ id, :db_hrt_class.fk_course_id ... );
end;
ON-INSERT trigger for SESSION data block:
begin
insert into hrt_session(fk_class_id,pk_session_type_id, fk_session_instructor_id ...)
values( :db_hrt_session.fk_class_id,
:db_hrt_session.FK_SESSION_TYPE_ID,
:db_hrt_session.FK_SESSION_INSTRUCTOR_ID );
end;
While the user completes the insert without error, the FK CLASS ID never gets populated with any value. I would like both the PK CLASS ID and the FK CLASS ID to have the same value as they are related this way, but it never happens. I have looked at it in the debugger and the value fo the FK CLASS ID is never populated (null).
Any comment, recommendation and/or solution is much appreicated.
Thanks in advance.
Barry
|
|
|
|
|