Thread View: borland.public.interbase.sql
3 messages
3 total messages
Started by Sergio Gonzalez
Tue, 03 Dec 2002 18:05
Simple SQL question (I guess)
Author: Sergio Gonzalez
Date: Tue, 03 Dec 2002 18:05
Date: Tue, 03 Dec 2002 18:05
35 lines
1947 bytes
1947 bytes
hello there! I'm a very begginer in SQL and have this problem. Just in case: I'm using IB 6.5 with Delphi 7 Sorry if this message is too large. And sorry for my English! I have these tables 1) ITEMS (id, description) 2) TCOST (tcost_id, description) 2) COST (id, tcost_id, percent) (id is FK to ITEMS and tcost_id is FK to TCOST) ie: ITEMS 1 SCREW 2 HAMMER TCOST 1 TAX 2 SHIPPING COST 1 1 nnn% 1 2 nnn% 2 1 nnn% 2 2 nnn% Each time I insert a record in TCOST, I need to insert one record per each row being in ITEM in the table COST. Can I do that with a simple SQL instruction? How can I do it? I supose that I should write a trigger in TCOST (after insert) THanks. Sergio.
Re: Simple SQL question (I guess)
Author: G. Allen Casteran
Date: Tue, 03 Dec 2002 23:32
Date: Tue, 03 Dec 2002 23:32
43 lines
1939 bytes
1939 bytes
Sergio, The best way to do this is an AFTER INSERT trigger on the Items table. Do you also need an AFTER DELETE? Allen In article <3decf30f@newsgroups.borland.com>, shg@sion.com says... > hello there! I'm a very begginer in SQL and have this problem. > Just in case: I'm using IB 6.5 with Delphi 7 > Sorry if this message is too large. And sorry for my English! > > I have these tables > 1) ITEMS (id, description) > 2) TCOST (tcost_id, description) > 2) COST (id, tcost_id, percent) (id is FK to ITEMS and tcost_id is FK to > TCOST) > > ie: > > ITEMS > 1 SCREW > 2 HAMMER > > TCOST > 1 TAX > 2 SHIPPING > > COST > 1 1 nnn% > 1 2 nnn% > 2 1 nnn% > 2 2 nnn% > > Each time I insert a record in TCOST, I need to insert one record per each > row being in ITEM in the table COST. > > Can I do that with a simple SQL instruction? How can I do it? > I supose that I should write a trigger in TCOST (after insert) > > THanks. > > Sergio.
Re: Simple SQL question (I guess)
Author: Sergio Gonzalez
Date: Wed, 04 Dec 2002 17:02
Date: Wed, 04 Dec 2002 17:02
30 lines
1960 bytes
1960 bytes
Thanks for replying Allen You're right. I guess I should use an AFTER INSERT trigger in Items also. Since I need the table COST be updated each time the ITEMS table grows and each time the TCOST table grows (I could append a new tax in the calculation on the cost of an item) Mi question is: is there a way to insert all the records together in a single INSERT statement? i.e.: if I insert a record in TCOST (lets say tcost_id = 3) then I need to insert in COST two records (id = 1, tcost_id = 3 and id = 2, tcost_id = 3) Hope I am clear, since my English is terrible and my SQL knowledge worst!!! Thanks! Sergio. "G. Allen Casteran" <allen@nisinc.com> escribi๏ฟฝ en el mensaje news:MPG.1856dee099f1cad4989686@forums.borland.com... > Sergio, > > The best way to do this is an AFTER INSERT trigger on the Items table. > Do you also need an AFTER DELETE? > > Allen
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads