Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help in updating records

Status
Not open for further replies.

dennis22

Programmer
Oct 8, 2002
32
I am a newbie in CF, hoping someone can help me.

This is the code I use to update a certain field:

<cfif #sAction# EQ "delete">
<cfquery name="qryDelete" datasource="mydata">
UPDATE xtable SET REMARKS = 'DELETE' WHERE TRIM(xtable.fieldname) IN ('fieldname','#strSql#')
</cfquery>
</cfif>

where the strSql has a value of '01','02','03'

I tried to print it just to see what it looks like, so this one works;

UPDATE xtable SET REMARKS = 'DELETE' WHERE TRIM(xtable.fieldname) IN ('fieldname','01')

but this one doesn't

UPDATE xtable SET REMARKS = 'DELETE' WHERE TRIM(xtable.fieldname) IN ('fieldname','01','02')

tried this command in mysql, it worked!

I'm confused???
 
do you get an error message? if so, what is it?


=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
 
I think the quotes around the numbers are throwing off the SQL Statement. Do they have to be there? You could either try removing them or using PreserveSingleQuotes() to keep them.


Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
Thanks for the replies!

There are no error messages flashing, but I tried ECAR's suggestion and it worked.

I did this in my code...

<cfif #sAction# EQ "delete">
<cfquery name="qryDelete" datasource="mydata">
UPDATE xtable SET REMARKS = 'DELETE' WHERE TRIM(xtable.fieldname) IN ('#preserveSingleQuotes(strSql)#')
</cfquery>
</cfif>

Thanks everyone! This site is the best!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top