Hello!
Ok, so no question too simple...
I'm using the perl dbi interface to postgres, and I'm wondering how
people do the following:
insert a row into a table, and then immediately get back the pkey/id
of the row, so that I can then use this id to insert into another related
table.
How would this be done in pure SQL, and/or is there a similar technique
to do this using the perl DBI and DBD::Pg?
Say I have a table named "Foo", which contains a not null constrained
foreign key to table "Bar": "Foo".bar_id.
Before I can insert a new row into table "Foo", I thus need to have the
related row in table "Bar", so I need to insert into "Bar" first, get the
pkey, and then insert "Foo".
Hope this makes sense - I'm sure it could be explained more presicely,
and it seems like it would be a very common scenerio/pattern.
Many thanks!
Corey