Solved

Expand variable embedded inside an sql table

Posted on 2006-11-08
3
312 Views
Last Modified: 2013-12-24
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


0
Comment
Question by:RollinNow
3 Comments
 
LVL 2

Expert Comment

by:pegarm
ID: 17904925
Try this:

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

<cfoutput>#evaluate(FilesInfo.description)#</cfoutput>
0
 
LVL 4

Accepted Solution

by:
CodeParadise earned 500 total points
ID: 17905110
The evaluate function wasn't working in my testing. You can also approach your problem this way.

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

<cfset var = "12345678">
<cfset newText = Replace(FilesInfo.description, "##variable##", var)>
<cfoutput>#newText#</cfoutput>
0
 

Author Comment

by:RollinNow
ID: 17909968
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
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question