Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: After update delete row id quantity is 0

Re: After update delete row id quantity is 0

From: DA Morgan <damorgan_at_psoug.org>
Date: Mon, 12 Mar 2007 08:43:43 -0700
Message-ID: <1173714224.383951@bubbleator.drizzle.com>


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.org
Received on Mon Mar 12 2007 - 10:43:43 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US