Mutating error in my trigger code
Hi,
Could anyone please help me out to fix the mutating error:
I have 2 tables z_errorpayment and z_errorcorrected.
If the status=2 in z_errorpayment table then a row has to be inserted in z_errorcorrected table and the same row has to be deleted from the 1st table i.e z_errorpayment.As it is retriving from the same table and deleting the same table am getting mutating error.
Below is the code.
CREATE OR REPLACE TRIGGER row_trigger
AFTER UPDATE
ON z_errorpayment
FOR EACH ROW
WHEN (NEW.status = 2)
BEGIN
INSERT INTO z_errorcorrected
(mtnl_error_payment_id, file_name, entry_date,
centre_code, service_code, instrument_flag,
instrument_no, subs_no, instrument_dt,
payment_mode, payment_dt, surchrg,
telephone_no, cheque_number, cheque_dt,
bank_code, pay_amount, receipt_no,
terminal_id, crtn_by, crtn_dt, remarks,
status, external_trans_id, transfer_date,
gl_uploaded_ind_code, task_queue_id,
user_name, old_payment_id, new_payment_id,
payment_type
VALUES (:NEW.mtnl_error_payment_id, :NEW.file_name, :NEW.entry_date,
:NEW.centre_code, :NEW.service_code, :NEW.instrument_flag,
:NEW.instrument_no, :NEW.subs_no, :NEW.instrument_dt,
:NEW.payment_mode, :NEW.payment_dt, :NEW.surchrg,
:NEW.telephone_no, :NEW.cheque_number, :NEW.cheque_dt,
:NEW.bank_code, :NEW.pay_amount, :NEW.receipt_no,
:NEW.terminal_id, :NEW.crtn_by, :NEW.crtn_dt, :NEW.remarks,
:NEW.status, :NEW.external_trans_id, :NEW.transfer_date,
:NEW.gl_uploaded_ind_code, :NEW.task_queue_id,
:NEW.user_name, :NEW.old_payment_id, :NEW.new_payment_id,
:NEW.payment_type
DELETE FROM z_errorpayment
WHERE new_payment_id = :NEW.new_payment_id;
END;
so I thought of using a view inorder to get rid of the mutating error.
But donno how to code it.
could anyone please help me out.
Regards,
Rupa
By using a view i wrote the below code:
CREATE OR REPLACE TRIGGER row_trigger
INSTEAD OF UPDATE
ON Z_ErrorView
FOR EACH ROW
DECLARE
X INTEGER;
BEGIN
SELECT STATUS into X FROM z_errorpayment WHERE new_payment_id = :NEW.new_payment_id;
IF X=2 THEN
INSERT INTO z_errorcorrected
(mtnl_error_payment_id, file_name, entry_date,
centre_code, service_code, instrument_flag,
instrument_no, subs_no, instrument_dt,
payment_mode, payment_dt, surchrg,
telephone_no, cheque_number, cheque_dt,
bank_code, pay_amount, receipt_no,
terminal_id, crtn_by, crtn_dt, remarks,
status, external_trans_id, transfer_date,
gl_uploaded_ind_code, task_queue_id,
user_name, old_payment_id, new_payment_id,
payment_type
VALUES (:NEW.mtnl_error_payment_id, :NEW.file_name, :NEW.entry_date,
:NEW.centre_code, :NEW.service_code, :NEW.instrument_flag,
:NEW.instrument_no, :NEW.subs_no, :NEW.instrument_dt,
:NEW.payment_mode, :NEW.payment_dt, :NEW.surchrg,
:NEW.telephone_no, :NEW.cheque_number, :NEW.cheque_dt,
:NEW.bank_code, :NEW.pay_amount, :NEW.receipt_no,
:NEW.terminal_id, :NEW.crtn_by, :NEW.crtn_dt, :NEW.remarks,
:NEW.status, :NEW.external_trans_id, :NEW.transfer_date,
:NEW.gl_uploaded_ind_code, :NEW.task_queue_id,
:NEW.user_name, :NEW.old_payment_id, :NEW.new_payment_id,
:NEW.payment_type
END IF;
DELETE FROM z_errorpayment
WHERE new_payment_id = :NEW.new_payment_id;
END;
Similar Messages
-
A SMALL EXAMPLE CODE FOR MUTATING ERROR
create or replace trigger TRG_T1
before insert on T1
begin
insert into T1 values(2);
end;
IF I TRY TO INSERT INTO T1 TABLE I GET A MUTATING ERROR HOW CAN I SOLVE??????joealexander wrote:
create or replace trigger TRG_T1
before insert on T1
begin
insert into T1 values(2);
end;
IF I TRY TO INSERT INTO T1 TABLE I GET A MUTATING ERROR HOW CAN I SOLVE??????
No, you do NOT get a mutating table error. You get this:
orcl112> create table t1(c1 number);
Table created.
Elapsed: 00:00:00.03
orcl112> create or replace trigger TRG_T1
2
3 before insert on T1
4
5 begin
6
7 insert into T1 values(2);
8
9 end;
10
11 /
Trigger created.
Elapsed: 00:00:00.04
orcl112> insert into t1 values (1);
insert into t1 values (1)
ERROR at line 1:
ORA-00036: maximum number of recursive SQL levels (50) exceeded
ORA-06512: at "SCOTT.TRG_T1", line 3
ORA-04088: error during execution of trigger 'SCOTT.TRG_T1'
ORA-06512: at "SCOTT.TRG_T1", line 3
ORA-04088: error during execution of trigger 'SCOTT.TRG_T1'
ORA-06512: at "SCOTT.TRG_T1", line 3
ORA-04088: error during execution of trigger 'SCOTT.TRG_T1'
ORA-06512: at "SCOTT.TRG_T1", line 3
ORA-04088: error during execution of trigger 'SCOTT.TRG_T1'
ORA-06512: at "SCOTT.TRG_T1", line 3
ORA-04088: error during execution of trigger 'SCOTT.TRG_T1'
You are the second person today who has claimed to have seen this error and posted code that did not raise it. What is going on? -
Help with Mutating Error / Trigger / APEX_MAIL.SEND
Hello:
I am trying to get the apex_mail.send function working when a user submits a new record. I've taken the code from the canned Issue Tracker application code and tried to retrofit it to my tables. However I keep receiving a mutating error on line 11 (line 11 bolded below):
-- Create a trigger that will send notification after
-- the submission of each new idea on the IDEAS table.
create or replace trigger IDEAS_EMAIL
AFTER
insert or update on IDEAS
for each row
begin
IF (INSERTING AND :new.manager_name IS NOT NULL)
OR
(UPDATING AND (:old.manager_name IS NULL OR :new.manager_name != :old.manager_name) AND :new.manager_name IS NOT NULL) THEN
FOR c1 IN
(SELECT fname, lname, email
FROM ideas_users
WHERE fname||' '||lname = :new.manager_name)
LOOP
IF c1.email IS NOT NULL THEN
FOR c2 IN
(SELECT MANAGER_NAME, FULL_TEXT, SUMMARY, ID, SUBMITTED_BY, SUB_DATE
FROM IDEAS
WHERE ID = :new.ID)
LOOP
APEX_MAIL.SEND(
p_to => c1.email,
p_from => c1.email,
p_body =>
'This is a test message. ' ||chr(10)||
p_subj => 'test email subject');
END LOOP;
END IF;
END LOOP;
END IF;
end;
I've also tried setting the following line to the primary key field in the user table and inserting that value into the main table but I still get the same error message.
WHERE fname||' '||lname = :new.manager_name)
Thanks in advance for any help.Let me get this straight..
You are inserting a row into a table, and when you insert the row, you are going to send an e-mail t o the manager who owns this row. In the data you are inserting, is the e-mail address of the manager, right?
David has provided the answer for you.. Use the :NEW.Email value instead of creating a cursor and all that.. Unless you have a need to e-mail multiple people of the record insert..
Thank you,
Tony Miller
Webster, TX
On the road of life...There are 'windshields', and there are 'bugs'
(splat!)
"Squeegees Wanted" -
URGENT : Trigger with Mutating Error
Hi,
I'm trying to write a trigger on a Table ROOM_BLOCK to update a value in table ROOM_OOI_OOS.
As given below, which works perfectly.
BEGIN
IF INSERTING THEN
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
ELSIF UPDATING THEN
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
ELSE
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
END IF;
END;
But when I add a select statement. the trigger seems to fail with a mutating error ORA-04091
and Error at Line which executes the statement immidiate ORA-04088.
DECLARE
stmt VARCHAR2(500);
vcount INTEGER;
BEGIN
IF INSERTING THEN
--INSERT INTO SHRUTI_TEST (DESCR) VALUES ('Inserting');
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
stmt := 'Select count(*) from ROOM_BLOCK ' ||
' WHERE ROOM_OOI_OOS_ID = ' || :NEW.ROOM_OOI_OOS_ID ||
' AND ROOM_NO = ''' || :NEW.ROOM_NO || ''' ';
EXECUTE IMMEDIATE stmt INTO vcount;
IF vcount = 1 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
END IF;
ELSIF UPDATING THEN
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
ELSE
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
END IF;
END;
Please tell me how to solve this problem...
Regards
Mike.Thank you for your reply to my posting.
I researched and used your recommendation. I was
wondering if you can help me resolve the following two
problems.
Table kassa1 has NAME and AGE columns. Table Kassa2
has one column Age.
I have created the following trigger. It keeps
raising a ORA-06519 : Active autonomous transaction
detected and rolled back error.
Create or replace trigger Name_Age_Row after insert or
update on Kassa1
For each row
Declare
Total_Age VARCHAR(8);
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
Select SUM(Age) into Total_Age from Kassa1;
insert into kassa2 values(Total_aAge);
End;
The following trigger also generates ORA-00036:
Maximum number of recursive SQL levels(50) exceeded
error.
Create or replace trigger Name_Age_Row after insert or
update on Kassa1
For each row
Declare
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
insert into kassa1 values('newname', 'newage');
End; -
Hi ,ihave created this trigger.its showing the mutating error as its selecting and updating the same table.So hw can we modify thsi trigger so that it worksd properly.
CREATE OR REPLACE TRIGGER resolutionimpact
AFTER INSERT OR UPDATE
ON PROBLEMS
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
newcause VARCHAR2(100);
oldcause VARCHAR2(10);
BEGIN
oldcause:=:OLD.PROM_NCCCAUSE;
newcause:=:NEW.PROM_NCCCAUSE;
IF newcause='100' THEN
UPDATE PROBLEMS SET PROM_IMPACT='CA_TCL FLP reset';
--PROM_IMPACT='CA_TCL FLP reset';
END IF;
END;No actually I am udating single row.Actually the value is being entered from the oracle form from front end and no matter whatever value we enter for prom_impact from front end it should overwrite that value with fixed value when we press the save button .Also we cannot do anything at form level as we have fmx and nt the fmb.So have to do it through trigger only.Also there is another trigger running on same table which fetches the value from problem table and inserts it into another table.So what can be done to solve the issue
-
Isn't this Trigger code error prone?
Version: 10g Release 2
I have come across a Trigger code where the :NEW pseudo variable is being assigned value like
SELECT emp_oid into :new.emp_oid FROM emp_dtls WHERE EMP_NO =:NEW.EMP_OID;Apparently, the code is working fine. But isn't this error prone?It is not very useful to post this single line. One doesn't even know on which table this trigger fires, nor the relationship with the affected table and the emp_dtls table, nor whether an exception handler was programmed.
(Probably not).
If my assumption is correct no exception handler was programmed, this would have resulted in kick-ass time, as the code may result in either the NO_DATA_FOUND exception or the TOO_MANY_ROWS exception.
Anyone writing that kind of code needs to be escorted to the door of unemployment immediately.
BTW will anything bad happen if you post a question consisting of more than 1 line. Salary substracted? Fingers chopped off by your boss?
Sybrand Bakker
Senior Oracle DBA -
How to avoid mutating error when insert or update record
Hi ,
I have one transaction table which is having some detail record under one transaction number, after the one transaction number is over by insert or update, i
want to check the total amounts of one flag should be matched on same table if it is not then give error message. But i am getting mutating error on insert or update event trigger on statement level trigger on above table.
Is there any other way to avoid mutating error to solve the above problem or some temp table concepts to be used. help me its urgent.
Thanks in advance,
Sachin Khaladkar
PuneSachin, here's as short of an example as I could come up with on the fly. The sample data is ficticious and for example only.
Let's say I need to keep a table of items by category and my business rule states that the items in the table within each category must total to 100% at all times. So I want to insert rows and then make sure any category added sums to 100% or I will rollback the transation. I can't sum the rows in a row-level trigger because I'd have to query the table and it is mutating (in the middle of being changed by a transaction). Even if I could query it while it is mutating, there may be multiple rows in a category with not all yet inserted, so checking the sum after each row is not useful.
So here I will create;
1. the item table
2. a package to hold my record collection (associative array) for the trigger code (the category is used as a key to the array; if I insert 3 rows for a given category, I only need to sum that category once, right?
3. a before statement trigger to initialize the record collection (since package variables hang around for the entire database session, I need to clear the array before the start of every DML (INSERT in this case) statement against the item table)
4. a before row trigger to collect categories being inserted
5. an after statement trigger to validate my business rule
I then insert some sample data so you can see how it works. Let me know if you have any questions about this.
SQL> CREATE TABLE item_t
2 (category NUMBER(2) NOT NULL
3 ,item_code VARCHAR2(2) NOT NULL
4 ,pct NUMBER(3,2) NOT NULL);
Table created.
SQL>
SQL> CREATE OR REPLACE PACKAGE trg_pkg IS
2 TYPE t_item_typ IS TABLE OF item_t.category%TYPE
3 INDEX BY PLS_INTEGER;
4 t_item t_item_typ;
5 t_empty_item t_item_typ;
6 END trg_pkg;
7 /
Package created.
SQL> SHOW ERRORS;
No errors.
SQL>
SQL> CREATE OR REPLACE TRIGGER item_bs_trg
2 BEFORE INSERT
3 ON item_t
4 BEGIN
5 DBMS_OUTPUT.put_line('Initializing...');
6 trg_pkg.t_item := trg_pkg.t_empty_item;
7 END item_bs_trg;
8 /
Trigger created.
SQL> SHOW ERRORS;
No errors.
SQL>
SQL> CREATE OR REPLACE TRIGGER item_br_trg
2 BEFORE INSERT
3 ON item_t
4 FOR EACH ROW
5 BEGIN
6 trg_pkg.t_item(:NEW.category) := :NEW.category;
7 DBMS_OUTPUT.put_line('Inserted Item for Category: '||:NEW.category);
8 END item_br_trg;
9 /
Trigger created.
SQL> SHOW ERRORS;
No errors.
SQL>
SQL> CREATE OR REPLACE TRIGGER item_as_trg
2 AFTER INSERT
3 ON item_t
4 DECLARE
5 CURSOR c_item (cp_category item_t.category%TYPE) IS
6 SELECT SUM(pct) pct
7 FROM item_t
8 WHERE category = cp_category;
9 BEGIN
10 DBMS_OUTPUT.put_line('Verifying...');
11 FOR i IN trg_pkg.t_item.FIRST..trg_pkg.t_item.LAST LOOP
12 DBMS_OUTPUT.put_line('Checking Category: '||trg_pkg.t_item(i));
13 FOR rec IN c_item(trg_pkg.t_item(i)) LOOP
14 IF rec.pct != 1 THEN
15 RAISE_APPLICATION_ERROR(-20001,'Category '||trg_pkg.t_item(i)||' total = '||rec.pct);
16 END IF;
17 END LOOP;
18 END LOOP;
19 END item_as_trg;
20 /
Trigger created.
SQL> SHOW ERRORS;
No errors.
SQL> INSERT INTO item_t
2 SELECT 1, 'AA', .3 FROM DUAL
3 UNION ALL
4 SELECT 2, 'AB', .6 FROM DUAL
5 UNION ALL
6 SELECT 1, 'AC', .2 FROM DUAL
7 UNION ALL
8 SELECT 3, 'AA', 1 FROM DUAL
9 UNION ALL
10 SELECT 1, 'AA', .5 FROM DUAL
11 UNION ALL
12 SELECT 2, 'AB', .4 FROM DUAL;
Initializing...
Inserted Item for Category: 1
Inserted Item for Category: 2
Inserted Item for Category: 1
Inserted Item for Category: 3
Inserted Item for Category: 1
Inserted Item for Category: 2
Verifying...
Checking Category: 1
Checking Category: 2
Checking Category: 3
6 rows created.
SQL>
SQL> SELECT * FROM item_t ORDER BY category, item_code, pct;
CATEGORY IT PCT
1 AA .3
1 AA .5
1 AC .2
2 AB .4
2 AB .6
3 AA 1
6 rows selected.
SQL>
SQL> INSERT INTO item_t
2 SELECT 4, 'AB', .5 FROM DUAL
3 UNION ALL
4 SELECT 5, 'AC', .2 FROM DUAL
5 UNION ALL
6 SELECT 5, 'AA', .5 FROM DUAL
7 UNION ALL
8 SELECT 4, 'AB', .5 FROM DUAL
9 UNION ALL
10 SELECT 4, 'AC', .4 FROM DUAL;
Initializing...
Inserted Item for Category: 4
Inserted Item for Category: 5
Inserted Item for Category: 5
Inserted Item for Category: 4
Inserted Item for Category: 4
Verifying...
Checking Category: 4
INSERT INTO item_t
ERROR at line 1:
ORA-20001: Category 4 total = 1.4
ORA-06512: at "PNOSKO.ITEM_AS_TRG", line 12
ORA-04088: error during execution of trigger 'PNOSKO.ITEM_AS_TRG'
SQL>
SQL> SELECT * FROM item_t ORDER BY category, item_code, pct;
CATEGORY IT PCT
1 AA .3
1 AA .5
1 AC .2
2 AB .4
2 AB .6
3 AA 1
6 rows selected.
SQL> -
How to handle the mutating error
create or replace trigger trg_t1
after insert on t1
begin
insert into t1 values(1);
end;
i got some error..1011927 wrote:
same table with the same trigger
Within trigger code do not issue SQL against same table upon which trigger is based; then no mutating error is thrown -
How to over come mutating error
Can Anyone explain me how to OVERCOME Mutating error when firing a trigger ?
Thanks in advance.1. Don't use triggers
2. Don't perform DML on the same table your trigger is based on.
Without information (such as your table create statement and your trigger code) there's not a lot else we can say right now.
If you're getting a mutating table error, it's an indication that either your logic or your design (or both!) need rethinking... -
Mutating error -oracle version 8i
I have a problem of mutating error in Oracle.If u have any solution kindly forward it to me.
I have a table e1 as shown below:
SQL>select * from e1;
code id transdate destination
The trigger is to fire after insert of a row
when "id" is 2.
The trigger calls a procedure which calculates a new
"transdate" and inserts a new record into the table e1 with
the newly calculated "transdate","id" as 12 and all the other
columns(code and destination)remains the same.
I have to pass "code" and "transdate" as input parameters to the
procedure.
Inside the procedure i have a select statement which fetches
the record from table e1(which is being inserted and fires a trigger).
This is the rootcause of the problem.
Since the trigger is firing after Insert,looping
happens and hence gives out the same error.
I even tried to use the PRAGMA AUTONOMOUS_TRANSACTION but it is not
supported in our version.
Please let me know if there is some other alternate to this.
--Regards,
Arthihttp://osi.oracle.com/~tkyte/Mutate/index.html
-
Master/Details tables with CASCADE delete giving "table mutating" error
Hi,
I have two tables in a master/details configuration (table 1 is "master", table 2 is "details").
The details has a FK contraint relation to the master with a CASCADE delete (so when the master is deleted, all associated details are deleted).
The master table has a column "last_updated_datetime" which is updated by a master table update trigger whenever most (excluding the last_updated_datetime column) columns are updated.
The details table has an update trigger which also updates the master table's last_updated_datetime column (whenever a detail row is changed).
The details table also has a delete trigger which also updated the master table's last_updated_datetime column (whenever a detail row is deleted).
The problem I have is: When the master record is deleted, which cascade deletes the details record(s), the delete trigger on the details table throws a "table is mutating" error.
I understand that the "mutating" error is "correct" because the master record is being deleted.
But is there some way I can get around this problem (for example, having the details table delete trigger not update the master table last_updated_datetime) when it's this cascade delete?
Thanks for your help!create table master (
id number primary key,
changed date not null
create table detail (
id number primary key,
master_id references master (id) on delete cascade
create or replace package pkg is
master_deleted boolean := false;
end;
create or replace trigger bds_master
before delete on master
begin
pkg.master_deleted := true;
end;
create or replace trigger ads_master
after delete on master
begin
pkg.master_deleted := false;
end;
create or replace trigger adr_detail
after delete on detail
for each row
begin
if not pkg.master_deleted then
update master
set changed = sysdate
where id = :old.master_id;
end if;
end;
insert into master values (1, sysdate - 10);
insert into detail values (11, 1);
insert into detail values (12, 1);
insert into master values (2, sysdate - 10);
insert into detail values (21, 2);
insert into detail values (22, 2);
insert into master values (3, sysdate - 10);
insert into detail values (31, 3);
insert into detail values (32, 3);
commit;
select * from master order by id;
ID CHANGED
1 01.09.08
2 01.09.08
3 01.09.08
select * from detail order by id;
ID MASTER_ID
11 1
12 1
21 2
22 2
31 3
32 3
delete detail where id = 21;
select * from master order by id;
ID CHANGED
1 01.09.08
2 11.09.08
3 01.09.08
select * from detail order by id;
ID MASTER_ID
11 1
12 1
22 2
31 3
32 3
delete master where id in (1, 2);
select * from master order by id;
ID CHANGED
3 01.09.08
select * from detail order by id;
ID MASTER_ID
31 3
32 3 Regards,
Zlatko
Edited by: Zlatko Sirotic on Sep 11, 2008 11:15 PM
This is disaster - ten attempts to format code! -
What is meant by Mutating error
Hi friends,
i am getting mutating error,
how to overcome this problem.
thanking u.
hemaTo over come its better follow
This package will contain yours rowid which is being insert of emp table
create or replace package state_pkg
as
type ridArray is table of rowid index by binary_integer;
newRows ridArray;
empty ridArray;
end;
This will flush or empty yours array wid empty one array cause there may be rowids
create or replace trigger emp_bi
before insert on emp
begin
state_pkg.newRows:=state_pkg.empty;
end;
This will move insert rows rowid in newRows array
create or replace trigger emp_ai
after insert on emp for each row
begin
state_pkg.newRows(state_pkg.newRows.count+1):=:new.rowid;
end;
This will backup yours data in empback which is being inserting in emp table note here at line 2 there is no for each row clause which means its statment level trigger and statment level trigger dont mutate because its fire at table level not for individaul rows.
create or replace trigger emp_aif
--> after insert on emp
begin
for i in 1..state_pkg.newRows.count
loop
insert into empback
select * from emp where rowid=state_pkg.newRows(i);
end loop;
end;
what this code does its just capture the rowids in a temp (newRows) array and then after getting insert records in table each row is fetching from emp table into empback on behalf of package array newRows (which contains rowid)
I hope u got it how to avoid mutate.
Khurram Siddiqui
[email protected] -
Error -- No Such Trigger('when-button-pressed')
Hi,
I am getting the error ""No Such Trigger('when-button-pressed')"",
when I am executing the code EXECUTE_TRIGGER( 'WHEN-BUTTON-PRESSED' );
on some item(Key-Next-Item), although WHEN-BUTTON-PRESSED trigger exists.
What could be the problem ?. It worked till yesterday, giving error from today, I havent
changed any thing.
Thanks in Advance
DevenderSteve's tip is the only good solution for this case.
The problem in your case for example is:
Let's say you have a block-trigger, which fires after your execute-trigger.
Now a colleague of you, which don't know your code, create a WHEN-BUTTON-PRESSED on an item, then the new code is started and not the block-trigger-code.
So, don't ever do this. Write your code in a package-function or -procedure and call it from the trigger. So you can re-user the functionality
Gerd -
Hi All,
I have a problem in creating a trigger.
I have two fields named last_updated_by, last_updated_date which
r common to all the tables.
If the user made any change to the exiting record, the values of
the those two colums should get changed automatically with the
username and sysdate.
When I wrote a trigger its giving mutation error.
Can I update these value by stored procedure via trigger?
I heard its possible by DBMS_JOB package. Can anyone give idea?
Thanks in Advance.
Regards
Gopinath KonaYou should only get the mutating table probllem if you're doing
SELCT or DML against the table the trigger's built on. Which
suggests that you're approaching this the wrong way.
Try CREATE TRIGGER blah blah
FOR EACH ROW
:new.last_updated_by := USER;
:new.last_updated_date := SYSDATE;
END;
If that's what you are doing then the problem lies elsewhere.
Rgds, APC -
XI - Call Adapter Error - HTTP client. Code 402 reason ICM_HTTP_TIMEOUT
I am using HTTP adapter to post XML PO to vendor's site. We are having this problem with one of our vendor when PO's has more than 15 line items. XI server is getting error-"Call Adapter Error - HTTP client. Code 402 reason ICM_HTTP_TIMEOUT". Actually PO is posted good for the first time on vendor's site but XI is getting above error message and it keeps posting it again. Is there anyway to stop it otherthan manually stopping the XI message? Is there anyway to increase the wait time of the XI server to get the message.
Thanks in advance.
Mrudula PatelI'm getting the same issue "500 TIMEOUT error" in runtime work bench-->IE--->Test Message. When i manually trigger the file.
The issue is basically from 01-01-2015 02:00 pm to 02-01-2015 01:am , File is picked from source ftp folder and places in archive but xml messages are not reflecting in SXMB_MONI.
Today suddenly after 01:00 am messages are successfully processing.
Please help on this issue. Many Thanks.
Maybe you are looking for
-
Can I add second credit card to my iTunes/Apple ID ?
Hi, can I add a second credit card to my account ? How ? thanks JP
-
WARNING The AdfFacesFilter has not been installed. ADF Faces requires this
The message: WARNING The AdfFacesFilter has not been installed. ADF Faces requires this filter for proper execution. is being displayed when I run my program. The program runs fine but I am wondering what causes this message and what can I do to solv
-
Regarding export excise invoice
Hi all, i need a clarification, my client is doing transaction for deemed export invoice, for that no excise duty will be there. while we are trying to cancel the excise invoice, it is giving message already utiliza
-
Encoding h.264 with an audio format other than AAC?
AME CC only lets me encode an h.264 with AAC audio, and that's the one format I *can't* use for this project! Without descending deep into the crazy world of ffmpeg command lines, is there any way to encode with AC3, WAV, MPEG-2, Vorbis, or FLAC? I h
-
Reshedule to another Production Line
Hi All, I have a material which can be manufactured in 2 work center. Now I have a capacity constarint at first work center. In CM21 , capacity levelling screen , how can i reschedule the prod order to another work center automatically? Amit