and don't forget the semicolon after the SQL statement to seperate the SQL for each iteration of the loop ;-)
Bryan Stevenson VP & Director of E-Commerce Development Electric Edge Systems Group Inc. p. 250.920.8830 e. [EMAIL PROTECTED] --------------------------------------------------------- Macromedia Associate Partner www.macromedia.com --------------------------------------------------------- Vancouver Island ColdFusion Users Group Founder & Director www.cfug-vancouverisland.com ----- Original Message ----- From: <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Wednesday, February 27, 2002 2:11 PM Subject: Re: RE: Inserting a delimited list into a database > In addition, if you want to reduce your database calls, you can alway > s > > do: > > <cfquery datasource="Software Updates" name="serverUpdate"> > > <CFLOOP INDEX="ServerID" LIST="#servers#" DELIMITER=" > ,"> > INSERT INTO [update] (log_id, server) > VALUES (#logQuery.id#,#ServerID#) > </CFLOOP> > </cfquery> > > That way, you're only doing one db call, that has multiple statemen > ts > > within it. > > Also, you should wrap the dynamic variables in the insert statement > > with <cfqueryparam> tags. > > ----- Original Message ----- > From: Matthew Walker <[EMAIL PROTECTED]> > Date: Wednesday, February 27, 2002 3:07 pm > Subject: RE: Inserting a delimited list into a database > > > Hey ho! The problem is having a table called Update! Try wrapping > > > [] around > > update. > > > > > > -----Original Message----- > > > From: Jake Munson [mailto:[EMAIL PROTECTED]] > > > Sent: Thursday, 28 February 2002 10:47 am > > > To: CF-Talk > > > Subject: Inserting a delimited list into a database > > > > > > > > > I have a form that returns a comma delimited list of > > > numbers from some checkboxes that each have the same name. > > > I want to be able to insert a new record in a database for > > > each checkbox that was checked in my form. I figured that > > > if I used a list loop based on my checkbox list, that I > > > could have a SQL query insert a record for each value in > > > the list. But it keeps giving me an error on the insert > > > query. Is it not possible to put a cfquery into a loop? > > > Is there a better way to do this? Below is my code. Below > > > that is the error I get. > > > > > > <CFLOOP INDEX="ServerID" LIST="#servers#" DELIM > ITER=","> > > > <cfquery datasource="Software Updates" name="serverUp > date"> > > > INSERT INTO update (log_id, server) > > > VALUES (#logQuery.id#,#ServerID#) > > > </cfquery> > > > </CFLOOP> > > > > > > "[Microsoft][ODBC Microsoft Access Driver] Syntax error > in > > > INSERT INTO statement. > > > > > > The error occurred while processing an element with a > > > general identifier of (CFQUERY), occupying document > > > position..." > > > > > > I thought that maybe the problem was that I didn't have a > > > cfoutput around the #ServerID#, but that wasn't the probl > em > > > either. > > > > > > Thanks for the help. > > > > > > -Jake > > > > > > ______________________ > _________________________ > ___ > > > Do You Yahoo!? > > > Yahoo! Greetings - Send FREE e-cards for every occasion! > > > > > > _______________________ > _________________________ > ______________________ > > Why Share? > > Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / > > > 20 GB MO/XFER > > Instant Activation · $99/Month · Free Setup > > http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc > > > FAQ: http://www.thenetprofits.co.uk/coldfusion/faq > > Archives: http://www.mail-archive.com/cf-talk@houseoffusion > com/ > > Unsubscribe: http://www.houseoffusion.com/index.cfm?sideb > ar=lists > > > ______________________________________________________________________ Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists