On Fri, 2012-03-16 at 12:28 -0400, Igor Tandetnik wrote: > On 3/16/2012 11:59 AM, Giuseppe Costanzi wrote: > > CREATE TRIGGER update_stocks AFTER INSERT ON transactions > > BEGIN > > UPDATE products > > SET > > products.stock =(CASE > > WHEN (transactions.flow =1 ) > > THEN SUM(products.stock + > > transactions.quantity) > > ELSE SUM(products.stock - > > transactions.quantity) > > END) > > > > WHERE products.product_id = transactions.product_id > > AND transactions.registered =1; > > END > > CREATE TRIGGER update_stocks AFTER INSERT ON transactions > BEGIN > UPDATE products SET stock = > (CASE WHEN new.flow = 1 > THEN stock + new.quantity > ELSE stock - new.quantity > END) > WHERE product_id = new.product_id > AND new.registered =1; > END; >
thank you very much Igor. _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

