Subject Re: [firebird-support] Re: Help with a trigger/procedure
Author Fabio Gomes
Ok, i ll simplify, i have 2 tables:



What i need to do is, when i change something on the first table, if the
Serial_number field is filled with something i need to update the second
table, I.E.

If i bought a product that had a serial number like: 123456 when i do this:

Insert into General (Product_id, Quantity, Serial_number) VALUES (01, 1,

I need to check if the serial number 123456 is on the Serials table, if
there is then i need to add 1 to the quantity, if there isnt any serial
numbers like 123456, i need to add a new row with the value 1.

I need to do it in any changes in the "general" table.

i dont know if i made it clear, hope you guys understand, my english isnt
very good and i dont know how can i explain this better.

Thanx in advance,


On 7/28/06, Adam <s3057043@...> wrote:
> --- In<>,
> "Fabio Gomes" <fabioxgn@...>
> wrote:
> >
> > Hum, so the main problem would be inserting the same value in the
> same table
> > at same time?
> >
> > Thinking about it, i think i can insert the new value in the table if it
> > doesnt exist and then always update it in the trigger event, so i can
> > always, insert the new value, commit imediatelly and after that start my
> > transaction.
> >
> > Would it be better?
> >
> > The method about using the table would work too, off course i have a
> table
> > with all the individual item values, but i like to keep that just for
> > reports and in case of something goes wrong and i have to recalc the
> total
> > stock of an item... i think it would be better to avoid that, i m afraid
> > this can slow down everything after i have too many rows there.
> >
> > Anyway, i m newbie so am open to any suggestions.
> From what you have explained, you have a table that has some totals
> consolidated in another table, but your explanation is far from clear
> which is why no specific suggestions have been made. This totalling
> means that two inserts may need to update a single record in the other
> table.
> Perhaps you can simplify your explanation a little, giving an example
> of the tables and what you want your trigger to do.
> Adam

[Non-text portions of this message have been removed]