On 3/28/07, Arora, Ajay <[EMAIL PROTECTED]> wrote:
Can anyone please look into my query,
I've tables
Master ( id integer primary key,
field1 text)
And
Child (id integer, name text)
My application receive values for field1 and name. I need to populate
master and child with incoming values using the same id.
1. Insert "field1" in Master;
2. Get id of record inserted from #1 above;
3. Insert id from #2 and "name" in Child.
That is about all the help I can provide given that you have not
provide any further context... what language you are using, how you
are developing the application, etc.
SQLite does provide a 'last_insert_rowid' capability. Look on the
sqlite.org website.
if you are 100% sure that no one else will be fiddling with your
database, you can probably use something like
INSERT INTO Child( id, name)
VALUES ( (SELECT Max(id) FROM Master), <name>)
A quick reply will be highly appreciated.
Regards
Ajay
-----Original Message-----
From: Arora, Ajay
Sent: 28 March 2007 15:04
To: 'sqlite-users@sqlite.org'
Subject: Maintaining Master-Child relationships
Hi,
I've two tables in my database, a master and a child with ID as a
common key.
I've created a table with one column to generate the sequence number.How
can I insert related records into both the tables using same ID?
Thanks
Ajay
THE INFORMATION CONTAINED IN THIS MESSAGE AND ANY ATTACHMENT MAY BE PRIVILEGED,
CONFIDENTIAL, PROPRIETARY OR OTHERWISE PROTECTED FROM DISCLOSURE. If the reader
of this message is not the intended recipient, you are hereby notified that any
dissemination, distribution, copying or use of this message and any attachment
is strictly prohibited. If you have received this message in error, please
notify us immediately by replying to the message and permanently delete it from
your computer and destroy any printout thereof.
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------
--
Puneet Kishor http://punkish.eidesis.org/
Nelson Inst. for Env. Studies, UW-Madison http://www.nelson.wisc.edu/
Open Source Geospatial Foundation http://www.osgeo.org/education/
---------------------------------------------------------------------
collaborate, communicate, compete
=====================================================================
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------