Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple table INSERT

Status
Not open for further replies.

lminmei

Programmer
Feb 1, 2000
111
US
How do I insert data from a form into multiple tables?
 
You would have to post the data from that one form to the next, using that value (#form.variable#) in each of your insert statement. You'll have a separate <cfquery> for each insert). Some more specifics if you have them might be helpful as well. Hope that helps.

V
 
Hey lminmei,

If you want the visitor to submit the form and have the same form inputs go into two different tables, this should do what you want.

<cfquery name=&quot;ins1&quot; datasource=&quot;ds2&quot;>
insert into tableName1 (field1,field2,...) values (#form.var1#,#form.var2#,..)
</cfquery>

<cfquery name=&quot;ins2&quot; datasource=&quot;ds2&quot;>
insert into tableName2 (field1,field2,...) values (#form.var1#,#form.var2#,..)
</cfquery>

Hope this helps,
GJ
 
Hey guys...thanx for the help...
But could i also use a stored procedure for this too?
 
Yes, you could write a stored procedure that took a set of values and inserted them into several tables. You would just call the stored proc once and pass it all of your form variables and if properly written, it would do the same thing as two <cfquery>s.

Good luck,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top