Subject RE: [firebird-support] Re: Help with a trigger/procedure
Author Alan McDonald
> Ok, i ll simplify, i have 2 tables:
>
> General
> id
> Product_id
> Quantity
> Serial_number
>
> Serials
> Serial_number(PK)
> Product_id(FK)
> Quantity
>
> 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,
> "123456");
>
> 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,
>
> Fábio.
I think it would be beter if you tell us what you want from this procedure
of updating/inserting. What is the resultant query you wish these actions to
make easier/faster - instead of what you want to implement.
Certainly you can trigger this action on tables or you can use an
update/insert SP to do it for you. But I smell some other issues.
After these actions have been taken, what query do you want to use and what
is the expected answer from it?
Alan