Update ColdFusion Query Columns With JavaCast

Social Share Toolbar

I recently found myself in need of a way to convert a Binary data column into Base64 encoded data when returning a query. After a quick Google, I was directed to Ben Nadel’s post “Updating Columns In An Existing ColdFusion Query Object” which details how to use javaCast to update a ColdFusion query.

From there, I just needed to add the small extra step of Base64 encoding and my query was ready to go.

<cfloop  query="q">
    <cfset base64Data = toBase64(q.my_binary_data) />
    <cfset q["my_binary_data"][q.currentRow] = javaCast("string",'#base64Data#') />

This is not the first time I found a useful solution on Ben’s site. If you use ColdFusion, you should definitely check it out. He has some great, easy-to-understand, posts on many useful topics.