ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 7th, 2005, 07:55 AM
bawaite bawaite is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 84 bawaite User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 50 m 45 sec
Reputation Power: 5
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

Reply With Quote
  #2  
Old June 7th, 2005, 08:03 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,682 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 42 m 54 sec
Reputation Power: 53
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.

Reply With Quote
  #3  
Old June 7th, 2005, 06:13 PM
VelvettFogg VelvettFogg is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 34 VelvettFogg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 13 m 46 sec
Reputation Power: 4
I think your last example would work if you put a semi-colon on the end of each line.

Reply With Quote
  #4  
Old June 8th, 2005, 07:37 AM
bawaite bawaite is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 84 bawaite User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 50 m 45 sec
Reputation Power: 5
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

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Insert multiple records in using one cfquery statement


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT