I have two tables whose common field is Load_ID. The PK of the first has a one-to-many relationship with the FK of the second. For example:
Table1:
1, someValue
Table2:
1, value1, ...
1, value2, ...
1, value3, ...
I've embedded the actual insert statement in an ASP.NET class where the values are taken from user input:
"INSERT INTO Compare_Header_Table VALUES
(compare_sequence.nextval, //other values are inserted here)
The sequence I'm using to auto-increment the PK is CREATE SEQUENCE compare_sequence;
This seems to work even without creating a trigger or specifying any parameters because the sequence defaults to an increment of 1 and an initial value of 1, which is fine for my purposes.
Where I'm running into problems is trying to link the FK from the second table to the PK of the first. I cannot simply use compare_sequence.currval
because I have a separate method for inserting into each table, so I'm creating a new connection each time. I don't want to combine these into one method because that will involve changing the logical structure of my C# class, which I'd rather leave intact.
Any suggestions for how to make this work?