Link to home
Start Free TrialLog in
Avatar of RollinNow
RollinNow

asked on

Expand variable embedded inside an sql table

How can I expand a variable which is embedded within a table column, itself expanded by a cfquery output?

A query, FilesInfo.description, is enclosed with cfoutput tags (see below). This is a column inside my sql table, data type varchar.

I want to edit the contents of FilesInfo.description and insert a variable in the middle of the text. When FilesInfo.description is expanded, the new variable is also expanded.

I guess you can see this as a variable within a variable, and it seems to me I read one cannot do this. But I'm hoping there is another way.

Here's the contents of "filesInfo.description".

"Story of a group of filmmakers traveled to Skull Island. <cfoutput>#variable#</cfoutput> They intended to investigate legends of a giant gorilla named Kong."

The problem is when expanded, #FilesInfo.description# displays my embedded variable name like this:

"This is the story of a group of explorers and documentary filmmakers traveled to Skull Island.  #variable# There they intend to investigate legends of a giant gorilla named Kong."

The variable is not expanded. Is there a workaround or a different method to do this without having to change my database design?


<cfquery name="FilesInfo" datasource="Library">
  select description
  from areas
  where area_id = #area_id#
</cfquery

<cfoutput>#FilesInfo.description#</cfoutput>

  - Georgia


Avatar of pegarm
pegarm

Try this:

<cfquery name="FilesInfo" datasource="Library">
  select description
  from areas
  where area_id = #area_id#
</cfquery

<cfoutput>#evaluate(FilesInfo.description)#</cfoutput>
ASKER CERTIFIED SOLUTION
Avatar of CodeParadise
CodeParadise

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RollinNow

ASKER

CodeParadise,

The evaluate function didn't work for me either, but your solution does. I should have thought of it. Makes sense.  However, to get it to work for me, I had to do this:

<cfset newText = Replace(FilesInfo.description, "babygunk", "#var#", "ALL")>

babygunk is just some text I know I'll never use so it's unique and does not need to be a set variable.  It replaces babygunk with my defined variable, var.

 Thanks for your help, and thanks, pegarm, for the attempt.


   - Georgia