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 Mike Lewis 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.

canblah

Technical User
Nov 1, 2001
5
0
0
CA
Is it possible to cfinsert to multiple tables? How would I do this?
Newbie
 
Sorry, I should add more details. A bit brain dead right now...
I have a form that submits four values to be added to four different tables.
 
Also, the information on the form is a drop-down list that the user selects from. I try to get the form to submit but I keep getting the error Syntax Error(missing operator) in query expression.

Help
 
Try using 4 different cfqueries and insert into a different table in each one.
Leslie
 
Thanks for the reply. This is what I have setup so far:

'Admin Page'

<FORM action=&quot;insert.cfm&quot; method=&quot;post&quot;>
<select type=&quot;text&quot; name=&quot;section1&quot;>
<option>less than 15 minutes</option>
<option>less than 30 minutes</option>
<option>less than 45 minutes</option>
<option>less than 60 minutes</option>
<option>more than 60 minutes</option>
</select>
<select type=&quot;text&quot; name=&quot;section2&quot;>
<option>less than 15 minutes</option>
<option>less than 30 minutes</option>
<option>less than 45 minutes</option>
<option>less than 60 minutes</option>
<option>more than 60 minutes</option>
</select>
etc... to four sections

time tag here
date tag here
</form>

'Insert Page'

<CFQUERY NAME=&quot;insert1&quot;
datasource=&quot;dbname&quot;>
insert into table1 (table1value, table1time, table1date)
values (#form.section1#, #form.time#, #form.date#)
</CFQUERY>

<CFQUERY NAME=&quot;insert2&quot;
datasource=&quot;dbname&quot;>
insert into table2 (table2value, table2time, table2date)
values (#form.section2#, #form.time#, #form.date#)
</CFQUERY>
etc... for the four values of the form

Then the Insert Page spits out the entered values as verification on the page.

But alas I encounter and error...
ODBC Error Code = 37000 (Syntax error or access violation)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'less than 15 minutes'.
The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (2:1) to (3:23).

Sorry for the long post...and thanks for the help

 
You'll need single ticks around #form.section1#:

<CFQUERY NAME=&quot;insert1&quot;
datasource=&quot;dbname&quot;>
insert into table1 (table1value, table1time, table1date)
values ('#form.section1#', #form.time#, #form.date#)
</CFQUERY>

Depending on the datatypes of the fields storing time and date data, we may have to deal with those next.
John Hoarty
jhoarty@quickestore.com
 
JHoarty,
Thanks for the help!
I have added the single quote as you suggested. I am now returning another error:

Error Diagnostic Information
ODBC Error Code = 07001 (Wrong number of parameters)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 3.
Hint: The cause of this error is usually that your query contains a reference to a field which does not exist. You should verify that the fields included in your query exist and that you have specified their names correctly.
The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (2:1) to (3:23).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top