Subject | Re: [firebird-support] How can i update multiple rows after a delete? |
---|---|
Author | Fabio Gomes |
Post date | 2005-11-21T12:08:15Z |
Thanks for the quick reply.
I started to use these procedures on my database, but i m with some
problems..
I ve altered the table products and added the filed actual_stock on it, then
i ve created the procedure to sum the added value with the actual stock.
But it isnt working when i have a null value in my actual_stock, like.. if i
add a new product, and the insert something in the stock _control table it
doesnt work, but if i have already an actual_stock value in my products
table, it works.
how can i solve this?
I m using ibwebadmin, and i didnt find how to put a default value (like 0)
on the actual_stock field.
Thanks in advance :)
I started to use these procedures on my database, but i m with some
problems..
I ve altered the table products and added the filed actual_stock on it, then
i ve created the procedure to sum the added value with the actual stock.
But it isnt working when i have a null value in my actual_stock, like.. if i
add a new product, and the insert something in the stock _control table it
doesnt work, but if i have already an actual_stock value in my products
table, it works.
how can i solve this?
I m using ibwebadmin, and i didnt find how to put a default value (like 0)
on the actual_stock field.
Thanks in advance :)
On 11/21/05, Adomas Urbanavicius <adomas@...> wrote:
>
> so, add that procedure into you trigger after insert,after delete..
> wherever
> execute procedure recalculate_sums(new/old.pro_id);
> where SP body something like
>
> update stocks set amount =
>
> (
> SELECT sum(Quantity) On_Hand
> FROM StockControl
> WHERE Pro_Id = :Pro_Id
> )
> where
> Pro_Id = :Pro_Id
>
>
> ps. just make sure about transactions, if two users in same time with
> same pro_id will work, I think you'll have to make transactions lock
> wait to update correctly.
>
> Fabio Gomes wrote:
>
> >Just another question,
> >
> >How can i make a function to update the actual_stock after i delete a
> row?
> >
> >This works when i insert a row:
> >
> >CREATE TRIGGER SCI ACTIVE AFTER INSERT AS
> >BEGIN
> >UPDATE STOCK
> >SET ACTUAL_STOCK = ACTUAL_STOCK + NEW.STOCK_ADDED
> >WHERE PRO_ID = NEW.PRO_ID;
> >END
> >
> >I want to make something like it:
> >
> >SELECT Pro_Id, sum(Quantity) On_Hand
> >FROM StockControl
> >WHERE Pro_Id = :Pro_Id
> >
> >I think that i need to make a function that actived after i delete
> >something, than it sum all the stock for that product and write it on the
> >actual_stock on the other table.
> >
> >is there some way to do it?
> >
> >Thanks guys :)
> >
> >
> >[Non-text portions of this message have been removed]
> >
> >
> >
> >
> >++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> >Visit http://firebird.sourceforge.net and click the Resources item
> >on the main (top) menu. Try Knowledgebase and FAQ links !
> >
> >Also search the knowledgebases at http://www.ibphoenix.com
> >
> >++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> >Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
>
> ------------------------------
> YAHOO! GROUPS LINKS
>
>
> - Visit your group "firebird-support<http://groups.yahoo.com/group/firebird-support>"
> on the web.
> - To unsubscribe from this group, send an email to:
> firebird-support-unsubscribe@yahoogroups.com<firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>
> - Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------
>
[Non-text portions of this message have been removed]