I've seen many similar questions & answers, but they've used other DB-specific tricks, or done it in code, etc. I'm looking for a straight SQL batch file solution (if it exists).
I have two tables with a parent/child relationship, call them Runs & Run_Values.
Runs has an "auto" generated PK, runID (a sequency & a trigger), and two colums, Model_Type & Time that ALSO uniquely identify the row (enforced with a constraint). For each row in Run, there are many entries in Run_Values, which has two columns, RunId & Value.
I'd like to generate something like this from the process that makes the data (mix of sql I know exists and SQL as I'd like it):
insert into Runs (Model_Type, Time) values ('model1', to_date('01-01-2009 14:47:00', 'MM-DD-YYYY HH24:MI:SS'));
set someVariable = SELECT runId FROM Runs WHERE Model_Type like 'model1' and Time = to_date('01-01-2009 14:47:00', 'MM-DD-YYYY HH24:MI:SS'));
insert into Run_Values (run_id, Value) values (someVariable, 1.0);
etc - lots more insert statements with Values for this model run.
Any thoughts, references, etc are appreciated.