开发者

Trigger calling a Stored Procedure

I couldn't get the output also couldn't find the problem.

Question:

Table : rent_info(cust_id,date_out,date_due_in,date_returned,fine)

This table is for a book rental one. At first while inserting I have to give cust_id,date_out(date when book is issued),date_due_in(which is 7 days after issue date). When the book is returned a trigger is used to insert data into rent_info table.

I have to give the date_returned. In trigger I have to calculate the fine which is 10$ for every days elapsed.

For returning I wrote a procedure that updates the table and inserts the return date. Then a trigger is created( a row-level trigger that checks for updates how much fine is to be paid). And as a last statement the the calculated fine is updated to the table.

The problem is that I could generate the fine amount but the update statement given to update the fine gives me a "table mutating error".

Can you please tell me where I went wrong. Sorry for not posting the code. I couldn't get the code from lab. If this information is 开发者_StackOverflow社区not enough I could try it in my system and post it here later.


Without code it's a bit tricky to guess how you tried to solve this problem, but it sounds like you have written an UPDATE statement to update the current row from within a row-level trigger.

That is impossible. You can't UPDATE a row that's in the process of being updated.

You can update the calculated fine by changing the value of ":new.fine" inside the trigger.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜