dbTalk Databases Forums  

Trigger Question

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Trigger Question in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
The Magnet
 
Posts: n/a

Default Trigger Question - 10-11-2010 , 01:49 PM






Hi,

We are running 10gR2.

We have a strange issue with our triggers, and it is probably
something we are missing. We have a table which has a BEFORE UPDATE
FOR EACH FOR on it and also an AFTER UPDATE table level trigger on it.

In order to help us debug it we have written out files during the
execution of the trigger. These files are the very first thing done.
You can see the declarations below.

When we run an update statement from SQLPLUS the triggers act normal
and output those files. But, when run through the application, the
BEFORE trigger does not put out any files but the AFTER trigger does,
which is causing issues.

How can an AFTER trigger fire without firing the BEFORE trigger? What
are we missing?

CREATE OR REPLACE TRIGGER ENGINE.order_line_bu_trg
BEFORE UPDATE ON ENGINE.ORDER_LINE FOR EACH ROW
DECLARE

v_file1 UTL_FILE.FILE_TYPE;

BEGIN
v_file1 := OPEN_FILES('/tmp','before_update.txt','w');
UTL_FILE.PUT_LINE(v_file1,'ORDER: ' || :NEW.order_id);
UTL_FILE.FCLOSE(v_file1);
order_suspension.save_order_id := :NEW.order_id;

======================

CREATE OR REPLACE TRIGGER ENGINE.order_line_au_trg
AFTER UPDATE ON ENGINE.ORDER_LINE
DECLARE

v_file2 UTL_FILE.FILE_TYPE;

BEGIN
v_file2 := OPEN_FILES('/tmp','after_update.txt','w');
UTL_FILE.PUT_LINE(v_file2,'CUSTOMER: ' ||
order_suspension.save_order_id );
UTL_FILE.FCLOSE(v_file2);

Reply With Quote
  #2  
Old   
The Magnet
 
Posts: n/a

Default Re: Trigger Question - 10-11-2010 , 02:18 PM






On Oct 11, 1:49*pm, The Magnet <a... (AT) unsu (DOT) com> wrote:
Quote:
Hi,

We are running 10gR2.

We have a strange issue with our triggers, and it is probably
something we are missing. *We have a table which has a BEFORE UPDATE
FOR EACH FOR on it and also an AFTER UPDATE table level trigger on it.

In order to help us debug it we have written out files during the
execution of the trigger. *These files are the very first thing done.
You can see the declarations below.

When we run an update statement from SQLPLUS the triggers act normal
and output those files. *But, when run through the application, the
BEFORE trigger does not put out any files but the AFTER trigger does,
which is causing issues.

How can an AFTER trigger fire without firing the BEFORE trigger? *What
are we missing?

CREATE OR REPLACE TRIGGER ENGINE.order_line_bu_trg
BEFORE UPDATE ON ENGINE.ORDER_LINE FOR EACH ROW
DECLARE

v_file1 * * * * *UTL_FILE.FILE_TYPE;

BEGIN
* *v_file1 := OPEN_FILES('/tmp','before_update.txt','w');
* *UTL_FILE.PUT_LINE(v_file1,'ORDER: ' || *:NEW.order_id);
* *UTL_FILE.FCLOSE(v_file1);
* *order_suspension.save_order_id := :NEW.order_id;

======================

CREATE OR REPLACE TRIGGER ENGINE.order_line_au_trg
AFTER UPDATE ON ENGINE.ORDER_LINE
DECLARE

v_file2 * * * * UTL_FILE.FILE_TYPE;

BEGIN
* v_file2 := OPEN_FILES('/tmp','after_update.txt','w');
* *UTL_FILE.PUT_LINE(v_file2,'CUSTOMER: ' ||
order_suspension.save_order_id );
* *UTL_FILE.FCLOSE(v_file2);

You know, developers can sometimes be so DUMB. Imaging, passing a
NULL code to the trigger and not coding for that condition.

Problem solved.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.