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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Query with function

Status
Not open for further replies.

minli98

IS-IT--Management
Aug 30, 2005
178
US
Hi all,

Say, I have a database table with columns X and Y. Column X contains some strings, and I want to parse these strings and place the results in column Y.

So I created the udf parseFunction(StringInput), but how do I run the update query in ColdFusion?

When I tried the following:
Code:
<cfquery name="updateY" datasource="myDSN">
update myTable
set Y = '#parseFunction(X)#'
</cfquery>
CF gave me an error because it expects X to be a CF variable rather than a table column. What is the right syntax to run the above?

I know I can do this by doing 2 queries (a select and update), but it took a long time to run.

Any thought? Many thanks in advance.

Min
 
if you write a CF function to do it, then you have to retrieve the data from the database before you can apply the function -- so this is your SELECT followed by UPDATE

much better would be a database function, not a CF function

r937.com | rudy.ca
 
Hi Rudy,

Thanks for the confirmation. I agree that doing it directly in db is much better, it's just my t-sql is a bit weak and it takes me longer to write a function in that platform.

Thanks!
Min
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top