Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: After update delete row id quantity is 0
alex_at_bibiano.es wrote:
> I have table A with columna KEY and QUANTITY
>
> Now I want write a trigger that ckecks after updating a row if
> quantity is 0. If quantiy is 0, I want to delete the row.
>
> Any sugestions?
>
> Thanks,
>
> Alex B.
This is not necessarily the brest approach the problem.
In your trigger check the result of the proposed update: Something like this:
IF :NEW.quantity = 0 THEN
or
IF :OLD.QUANTITY - :NEW.QUANTITY = 0 THEN
If it is then don't perform the update in the first place. Better yet
determine the result before the update and don't use a trigger at all.
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Group www.psoug.orgReceived on Mon Mar 12 2007 - 10:43:43 CDT
![]() |
![]() |