Subject | RE: [firebird-support] master updation using trigger |
---|---|
Author | Alan McDonald |
Post date | 2006-07-30T23:31:07Z |
> Hello,for stock levels, always insert 1 for increment and -1 for decrement.
>
> 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
>
> Thank you.
>
> Sudheer Palaparambil
housekeeping is a procedure which groups the sum of stocktype and replaces
the starting balance with the value and deleting the increments and
decrements. Then your system continues with inserting 1 and -1 again
Alan