Ask a Question related to Macromedia ColdFusion, Design and Development.
-
JakeFlynn #1
Coldfusion expression stored inside a variable...
I have a Coldfusion expression stored inside a coldfusion variable, for example:
<cfsavecontent time = #CreateODBCDateTime(now())#>
if i do not put cfoutputs around #CreateODBCDateTime(now())# then the var will
equal #CreateODBCDateTime(date)# this is what i want because that will get
stored and then later called:
<cfoutput>#time#</cfoutput>
now i would like that to output as the literal date eg(01/01/99) not
#CreateODBCDateTime(date)# but all it will do is output
#CreateODBCDateTime(date)# so basically is there any way to parse a statement
twice?
JakeFlynn Guest
-
javascript, coldfusion expression
hi guys! is there a way to embed a expression using javascript and coldfusion values? this variable is getting nut... <a... -
coldfusion variable inside a css doc
You can have a dynamic style sheet. You can use cfcontent to return the MIME type text/css. The only problem with this is that it prevents the... -
coldfusion variable inside a css doc
You can actually have dynamic style sheets although I've never done it. There are a few guides out there for doing it in php so i can't imagine it's... -
JavaScript? Putting a variable in the midst of a Regular Expression.
I was reading a great article by Kas Thomas, "Save Yourself Some Typing with 'With'" at PlanetPDF. I really don't care much for the term guru, I... -
Does DB2 does implict commit inside Stored Procedure
Hi, I written a stored procedure which does update to a table in stages. I implemented this using a while loop and udating fixed number of rows in... -
JakeFlynn #2
Re: Coldfusion expression stored inside a variable...
to explain what i am trying to do a little better i will add a more complete
example
<cfsavecontent
variable = "cust_query">
select * from table1 where
entered_date >= #CreateDate(Year(Now()), Month(Now()), 1)#
</cfsavecontent>
then... #cust_query# is stored in a database table as is:
insert into table1
values('select * from table1 where
entered_date >= #CreateDate(Year(Now()), Month(Now()), 1)#')
later i want to retrieve it and run it....
<CFQUERY name="cases" datasource="#Application.DSNIntranet#">
#custom_search.query_sql#
</CFQUERY>
but it says that sql does not know function #CreateDate(Year(Now()),
Month(Now()), 1)# because obviously that is a cf function that is not getting
parsed
JakeFlynn Guest
-
basky #3
Re: Coldfusion expression stored inside a variable...
One way of solving this is to use some kind place holders for the date in the
saved query.
Ex:
select * from table1 where
entered_date >= %CURRENT_DATE%
While executing this query you can say
<CFQUERY name="cases" datasource="#Application.DSNIntranet#">
#replaceNoCase(custom_search.query_sql, "%CURRENT_DATE%",
CreateDate(Year(Now()), Month(Now()), 1), "all")#
</CFQUERY>
You can such multiple place holders in the query and you should search and
replace all these dynamic parameters at the runtime.
basky Guest
-
JakeFlynn #4
Re: Coldfusion expression stored inside a variable...
Basky thank you for your reply if I use the replace like that are you sure that it will then get parsed when it is needed?
JakeFlynn Guest
-
basky #5
Re: Coldfusion expression stored inside a variable...
It sure will. There is no parsing involved here, you are just replacing the
occurrences of a substring with in a string.
Just want to make it clear once again, replace function is used on the saved
query (that is stored in the database in string format), replaceAll function
call is not part of the stored query string.
basky Guest
-
OldCFer #6
Re: Coldfusion expression stored inside a variable...
You might look at using DB functions for this sort of thing. I don't know how
complicated
these queries are going to get so it's hard to say.
select * from table1 where
entered_date >= GetDate()
This would work for MSSQL and could be used directly.
OldCFer Guest
-
JakeFlynn #7
Re: Coldfusion expression stored inside a variable...
OldCFer thank you for your reply, the date's were a bit complicated and i had
already done the conversions needed in CF so i wanted to reuse that code. I
ended up using you suggestion and just doing the dates in sql thanks
JakeFlynn Guest



Reply With Quote

