Skip to content
Advertisement

My PLSQL trigger is not looping through the table

I have a group project and we are using PLSQL to make a shopping cart application. We are creating a trigger in order to cancel a shopping cart and return all of the items back to stock. As it is now, if you add multiple items to your cart, when the trigger runs, it only adds back the stock of one product, not all, so for some reason, the trigger is not looping through. Our project is due tomorrow so please help!

We need the code to go through each row of the table and return each item in the cart back to stock.

Advertisement

Answer

I urge you to not put all this code in a trigger, but instead create a cancel_order procedure like this:

You then call this procedure as needed, but not from inside a trigger.

You should avoid SQL statements inside triggers. There is too much potential for side effects and mutating table errors.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement