This is a multi-part message in MIME format.
------=_NextPart_000_0013_01C03C28.9D83E8C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
What am I doing wrong? I'm trying to update multiple rows in my =
database as follows:
FORM:
<!--- Allows users to define directory that will be renamed (path) and =
what the new directory name will be (directory_name) . . . path is =
actually chosen via a cool javascript tree (mytree) on the previous page =
and then passed to this form --->
<INPUT type=3D"hidden" name=3D"path" value=3D"#mytree.path#">
<INPUT type=3D"text" name=3D"directory_name" maxlength=3D"20" =
size=3D"20">
Once I define what directory will be renamed, I then use CFDIRECTORY to =
rename it (works fine, not represented here), but then need to update my =
database to account for the new directory name:
ACTION PAGE:
. . .=20
<!--- Find records that need to be updated --->
<CFQUERY NAME=3D"renamefilelist" DATASOURCE=3D"files">
SELECT file_name, number
FROM Files
WHERE file_name LIKE '#form.path#%'
</CFQUERY>
<!--- Set array to assign new file name to each file found in =
renamefilelist query --->
<cfset name=3Darraynew(1)>
<cfloop query=3D"renamefilelist">
<cfset name[number]=3D#Replace(file_name, "#form.path#", =
"#GetDirectoryFromPath(form.path)##form.directory_name#", "ALL")#>
</cfloop>
<!--- Output results to see if this works so far . . . NOTE: the output =
is perfect! --->
<cfoutput query=3D"renamefilelist">
#file_name#<br>
#name[renamefilelist.number]#<br><br>
</cfoutput>
<!--- Actually update the database . . . .this is where things go wrong =
. . . --->
<CFQUERY NAME=3D"rename" DATASOURCE=3D"files">
UPDATE files
SET file_name=3D'#name[renamefilelist.number]#'
WHERE number IN (#ValueList(renamefilelist.number)#)
</cfquery>
The updates to the database result in each file_name for each record =
being changed to the same new name . . . the first name it finds in the =
query.
Any suggestions?
Barbara J. Smith
------=_NextPart_000_0013_01C03C28.9D83E8C0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>What am I doing wrong? I'm trying =
to update=20
multiple rows in my database as follows:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>FORM:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><!--- Allows users to define =
directory=20
that will be renamed (path) and what the new directory name will be=20
(directory_name) . . . path is actually chosen via a cool javascript =
tree=20
(mytree) on the previous page and then passed to this form =
---></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><INPUT type=3D"hidden" name=3D"path" =
value=3D"#mytree.path#"></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><INPUT type=3D"text" =
name=3D"directory_name"=20
maxlength=3D"20" size=3D"20"></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Once I define what directory will be =
renamed, I=20
then use CFDIRECTORY to rename it (works fine, not represented here), =
but then=20
need to update my database to account for the new directory =
name:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>ACTION PAGE:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>. . . <BR></FONT><FONT face=3DArial =
size=3D2><!---=20
Find records that need to be updated ---></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><CFQUERY NAME=3D"renamefilelist"=20
DATASOURCE=3D"files"><BR>SELECT file_name, number<BR>FROM =
Files<BR>WHERE=20
file_name LIKE '#form.path#%'<BR></CFQUERY></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2><!--- Set array to assign new file =
name to each=20
file found in renamefilelist query ---><BR><cfset=20
name=3Darraynew(1)><BR><cfloop =
query=3D"renamefilelist"><BR> <cfset=20
name[number]=3D#Replace(file_name, "#form.path#",=20
"#GetDirectoryFromPath(form.path)##form.directory_name#",=20
"ALL")#><BR> </cfloop></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2><!--- Output results to see if this =
works so far=20
. . . NOTE: the output is perfect! ---></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><cfoutput=20
query=3D"renamefilelist"><BR>#file_name#<br><BR>#name[renamefile=
list.number]#<br><br><BR></cfoutput></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2><!--- Actually update the database . =
. . .this=20
is where things go wrong . . . ---></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><CFQUERY NAME=3D"rename"=20
DATASOURCE=3D"files"><BR>UPDATE files<BR>SET=20
file_name=3D'#name[renamefilelist.number]#'<BR>WHERE number =
IN=20
(#ValueList(renamefilelist.number)#)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></cfquery></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>The updates to the database result in =
each=20
file_name for each record being changed to the same new name . . . the =
first=20
name it finds in the query.<BR>Any suggestions?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Barbara J. =
Smith</DIV></FONT></BODY></HTML>
------=_NextPart_000_0013_01C03C28.9D83E8C0--
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message
with 'unsubscribe' in the body to [EMAIL PROTECTED]