Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

update trigger is not working...

Sumit GujarApr 30 2012 — edited May 2 2012
Hi
I am writing an update trigger.
We have a two DB, one is application DB and other is reporting DB. We are writing trigger on Reporting DB. There is a job schedule for synchronizing the application data to reporting DB , this daly basis synchronization. So when the synchronization runs and if the FUNDING_RULE_TABLE is updated them my trigger gets called.

CREATE OR REPLACE
TRIGGER COMM_EXISTING_REP_TRIGGER AFTER UPDATE OF FR_IR_NAME ON FUNDING_RULE_TABLE
DECLARE
serialno INTEGER;

CURSOR C_CES_REP IS
Select distinct FR_IR_NAME,FR_IR_CODE from FUNDING_RULE_TABLE ;
V_IR_NAME FUNDING_RULE_TABLE.FR_IR_NAME%TYPE;
V_IR_CODE FUNDING_RULE_TABLE.FR_IR_CODE%TYPE;

CURSOR C_CES_COMIT IS
SELECT DISTINCT FR_IR_NAME1,FR_IR_CODE from COMM_EXSTS_COMIT_AGGR;
IR_NAME VARCHAR2(20);
IR_CODE VARCHAR2(10);

BEGIN
OPEN C_CES_REP;
LOOP
FETCH C_CES_REP INTO V_IR_NAME,V_IR_CODE;
IF C_CES_REP%NOTFOUND THEN
EXIT;
END IF;

OPEN C_CES_COMIT;
LOOP
FETCH C_CES_COMIT INTO IR_NAME,IR_CODE;
IF(V_IR_CODE = IR_CODE AND V_IR_NAME = IR_NAME) THEN
EXIT;
ELSE
update COMM_EXSTS_COMIT_AGGR set FR_IR_NAME1 = IR_NAME where FR_IR_CODE = IR_CODE;
END IF;
END LOOP;
CLOSE C_CES_COMIT;

END LOOP;
CLOSE C_CES_REP;
END COMM_EXISTING_REP_TRIGGER;


The problem is:

When the synchronization runs the trigger will gets called and the synchronization prc never stops because of the table locks.
1) why some tables are getting locks? (I think this is becuse some source is waiting for another to release-deadlock)
2) Is there any problem in trigger? (I think there is some problem is trigger)
3) When I comment below part then sync procedure works fine
OPEN C_CES_COMIT;
LOOP
FETCH C_CES_COMIT INTO IR_NAME,IR_CODE;
IF(V_IR_CODE = IR_CODE AND V_IR_NAME = IR_NAME) THEN
EXIT;
ELSE
update COMM_EXSTS_COMIT_AGGR set FR_IR_NAME1 = IR_NAME where FR_IR_CODE = IR_CODE;
END IF;
END LOOP;
CLOSE C_CES_COMIT;
It menas that there is somr problem in trigger because i am reading and updation is performed on the same table "COMM_EXSTS_COMIT_AGGR ".

Is this is the problem?

waitting for ur rply...thx..

Edited by: 931005 on Apr 30, 2012 2:38 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 30 2012
Added on Apr 30 2012
3 comments
331 views