Adobe Dreamweaver Forums



Last 10 THreads :         Re: Unable to authenticate installer (Last Post : D Sparks - Replies : 1 - Views : 2 )           »          Microphone in the latest beta (Last Post : 0x656b694d - Replies : 0 - Views : 1 )           »          Please help me (Last Post : HalfNelson - Replies : 0 - Views : 1 )           »          Re: Fireworks screws up colors from photoshop (Last Post : chirp88 - Replies : 5 - Views : 6 )           »          CFdirectory recurse error (Last Post : Adam Cameron - Replies : 1 - Views : 2 )           »          Coldfusion Login (Last Post : ProjectedSurplus - Replies : 0 - Views : 1 )           »          CFC Path works on dev but not in production (Last Post : Adam Cameron - Replies : 1 - Views : 2 )           »          Application Variables vs Request Variables (Last Post : Adam Cameron - Replies : 22 - Views : 23 )           »          COMPLETELY CONFUSED (Last Post : texjgc - Replies : 10 - Views : 11 )           »          Re: Threads when they are done (Last Post : Adam Cameron - Replies : 1 - Views : 2 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Cold Fusion
 
Tags: ,

Reply
  #1 (permalink)  
Old 07-24-2008, 06:31 PM
chrispilie
 
Posts: n/a
Diggs:
Default loop over query

I have an access database table that contains a column that I would change all
the values to the same variable. The table is forever being populated with more
rows as data is entered regularly. I have tried numerous attempts to build an
insert query inside cfloop tags and I never seem to get the right result. Here
is a snipet.

<cfif FORM.Updated IS "no">
<CFLOOP INDEX="Update" LIST="#FORM.Updated#">
<CFQUERY Name="#Update#" DataSource="#db#">
INSERT INTO QTYTracking (Updated)
VALUES ('#FORM.Updated#')</CFQUERY></CFLOOP>
</cfif>

Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-24-2008, 06:41 PM
Dan Bracuk
 
Posts: n/a
Diggs:
Default Re: loop over query

You realize that insert queries don't update existing rows, right?
Reply With Quote
  #3 (permalink)  
Old 07-24-2008, 07:27 PM
chrispilie
 
Posts: n/a
Diggs:
Default Re: loop over query

AH... Lazy copy and paste error. The UPDATE worked. Time for some coffee!
Reply With Quote
  #4 (permalink)  
Old 07-24-2008, 07:27 PM
Ian Skinner
 
Posts: n/a
Diggs:
Default Re: loop over query

chrispilie wrote:
> AH... Lazy copy and paste error. The UPDATE worked. Time for some coffee!


I presume that means you correct your INSERT|UPDATE logic so that you
get a different value each loop? Because in your original post, the
logic would produce the same value for every record put|changed in the
database.

<CFLOOP INDEX="Update" LIST="#FORM.Updated#">
<CFQUERY Name="#Update#" DataSource="#db#">
INSERT INTO QTYTracking (Updated)
VALUES ('#FORM.Updated#')</CFQUERY></CFLOOP>
</cfif>


If form.Updated equaled the list 'red,white,blue' Then three values
would be put into the database, but the 'Updated' column of all three
would equal 'red,white,blue'. I would usually expect a loop like this
to put three separate values and thus it would look something like this.

<CFLOOP INDEX="Update" LIST="#FORM.Updated#">
<CFQUERY Name="#Update#" DataSource="#db#">
INSERT INTO QTYTracking (Updated)
VALUES ('#Update#')</CFQUERY></CFLOOP>
</cfif>

But maybe that is not the desired result.
Reply With Quote
  #5 (permalink)  
Old 07-24-2008, 08:18 PM
Dan Bracuk
 
Posts: n/a
Diggs:
Default Re: loop over query

[q]Originally posted by: chrispilie
AH... Lazy copy and paste error. The UPDATE worked. Time for some coffee![/q]
When you come back, look at your code again and figure out how to do it
without a loop.

Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 10:27 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk