Subject Re: master updation using trigger
Author Adam
--- In firebird-support@yahoogroups.com, "Sudheer Palaparambil"
<sudheer.clt@...> wrote:
>
> Hello,
>
> Is it safe to reduce the quantity and check for closing stock in the
> product master file using a trigger like this in a multi-user
> environment?
>
> Trigger for sale_det before insert :-
>
>
> IF ( NEW.cancelled = 0 ) THEN BEGIN /* Not cancelled. */
> UPDATE product SET closing = closing - ( NEW.quantity + NEW.free )
> WHERE ( company_id = NEW.company_id ) AND ( product_id =
NEW.product_id);
>
> SELECT closing FROM product
> WHERE ( company_id = NEW.company_id ) AND ( product_id =
NEW.product_id)
> INTO :liClosing;
>
> IF ( liClosing < 0 ) THEN EXCEPTION INVALID_SALE_QUANTITY;
> END

No

Adam