|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Insert multiple records in using one cfquery statement
How could I go about adding multiple records to the same access database table using only one cfquery.
I have tried: Code:
<cfquery name="add_items" datasource="#ds#">
INSERT INTO table (sName, sDescription, sStart_Date, sEnd_Date)VALUES
('#sName#', '#sDescription#', #sDate#, #eDate#)
('#sName#', '#sDescription#', #sDate#, #eDate#)
</cfquery>
Code:
<cfquery name="add_items" datasource="#ds#">
INSERT INTO table (sName, sDescription, sStart_Date, sEnd_Date)VALUES
('#sName#', '#sDescription#', #sDate#, #eDate#),
('#sName#', '#sDescription#', #sDate#, #eDate#)
</cfquery>
Code:
<cfquery name="add_items" datasource="#ds#">
INSERT INTO table (sName, sDescription, sStart_Date, sEnd_Date)
VALUES('#sName#', '#sDescription#', #sDate#, #eDate#)
VALUES('#sName#', '#sDescription#', #sDate#, #eDate#)
</cfquery>
Code:
<cfquery name="add_items" datasource="#ds#">
INSERT INTO table (sName, sDescription, sStart_Date, sEnd_Date)VALUES('#sName#', '#sDescription#', #sDate#, #eDate#)
INSERT INTO table (sName, sDescription, sStart_Date, sEnd_Date)VALUES('#sName#', '#sDescription#', #sDate#, #eDate#)
</cfquery>
they all give me an error of: Syntax error in INSERT INTO How can I go about adding multiple record to the same MS Access database table using only one cfquery statement? thank you |
|
#2
|
|||
|
|||
|
Not sure this is possible, and if it is, it will surely not be simple. As far as I know the way this is done is to run multiple queries inside a cftransaction block.
An added note that this IS possible when selected data from one table to insert into another table. But that is a different need than the one you are after.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums Last edited by kiteless : June 7th, 2005 at 08:08 AM. |
|
#3
|
|||
|
|||
|
I think your last example would work if you put a semi-colon on the end of each line.
|
|
#4
|
|||
|
|||
|
Thanks VelvettFogg but I tried that also after I posted this and it said that there items after the ';' and would not process fully, I ended up doing as I have done in the past, as kiteless said to just use multiple cfquery'.
Thank you |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Insert multiple records in using one cfquery statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|