Subject Help with a trigger/procedure
Author Fabio Gomes
Hi guys, i newbie in firebird, and hope you guys can give me some
tips, examples, tutorials, etc...

I ll explain what i need to do and i hope you guys can help me out...

I m working on a stock control software, and i need to control the
serial number of each item, and i m thinking about making it all using
firebird triggers and/or procedures...

I ll try to explain what i need.. i have 2 tables, one that have the
general stock history, and other with the current stock of each item
(i used the serial number as primary key).

What i need to do is:

When i change something in the stock history table, i need a trigger
or procedure to make a select or something like that to see if that
serial number is already on the other table, if it is alredy there,
then i need to get the quantity that i m changing, inserting, or
removing in the history table and sum with the actual quantity on
there.

And if i add a new item on the stock history it needs to check the
other table if the item is already there, if it is it updates, if it
is not, it adds...


So.. any tips you guys can give me to make this are welcome, i m
newbie in firebird and the only thing i know is how to make a trigger
to generate the table ids and simple stuff like that.. i never worked
with stored procedures or things like this.

Could guys give me some guidance please?

thanx in advance,

Fábio.