Greetings,

I have what is, I think, a very basic SQL question, but I don't seem to be able to find the answer. I'm almost a complete database novice, so perhaps I have things completely wrong… I want to insert a row into one table and have it automatically generate a primary key (the other fields in the insert are not going to be unique, only the primary key is sure to be unique). I then want to add some rows to other tables that refer to the first row with a foreign key. So my question is, how do I obtain the value of the first row's primary key, and how do I use it as a foreign key in the subsequent inserts?

The last_insert_rowid() function seems to be close to what I want. The trouble with it is that as soon as I add a row to the first child table its value will change and I will not be able to use it for any other child inserts.

Thanks,

Rob.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to