inserting data into two tables with a keyfield
Posted: Wed Jan 04, 2012 11:11 pm
Hi all,
As my previous thread, I've got data from text fields to populate my table. So far, Ive got 3 fields in the Customer table C_ID (Primary - Auto Increment) , FName and SName. I've got another table called Address which includes the following fields C_ID (this is going to be the keyfield that relates back to Customer ) , Address1, Address2 and Zip.
I can insert into the Customer table with the values that have been typed in on my form, but after I've 'committed' the record in the Customer table - C_ID populates/increments - I need to retrieve this and use the value in the Insert for the Address table. Am I right in thinking I need write two insert statements; write the first to the customer table, retrieve C_ID and then write the second insert to the Address or is their a 'funky' way in Livecode that will allow me to quickly write related data in the correct tables quite easily.
If I do need to write two insert statements what command do I need to use to retrieve the C_ID and I suppose it needs to go in after the revExecuteSQL conID, tSQL
Thanks all
As my previous thread, I've got data from text fields to populate my table. So far, Ive got 3 fields in the Customer table C_ID (Primary - Auto Increment) , FName and SName. I've got another table called Address which includes the following fields C_ID (this is going to be the keyfield that relates back to Customer ) , Address1, Address2 and Zip.
I can insert into the Customer table with the values that have been typed in on my form, but after I've 'committed' the record in the Customer table - C_ID populates/increments - I need to retrieve this and use the value in the Insert for the Address table. Am I right in thinking I need write two insert statements; write the first to the customer table, retrieve C_ID and then write the second insert to the Address or is their a 'funky' way in Livecode that will allow me to quickly write related data in the correct tables quite easily.
If I do need to write two insert statements what command do I need to use to retrieve the C_ID and I suppose it needs to go in after the revExecuteSQL conID, tSQL
Thanks all