Ahh, the sound of yesterday, the delicious bouquet of simpler times,
when I was younger, thinner, flexible, and spent my time in the
pursuits of youth...

Like sitting at my desk screaming "WHY WON'T THIS EFFING THING WORK?!?!?!?"

Only to realize that I was making the most elemental of mistakes. A
missing hash, a missing paren, trying to give JavaScript access to a
CF Query object, directly...

Simpler times, younger software, Segment Faults in CFStudio, WinNT 4,
and mod_coldfusion.so with Apache 1.1 or Window PWS.

Funny, almost jarring, how a question on a list can bring back a whole
FLOOD of memories... I think back fondly, but very generically, of my
earlier days working with CF. This question, for some reason, really
REALLY brought back a whole fleet of very specific, very vivid
memories. I suppose having found backup CDs from 1998 with my first
half-dozen CF apps on them really added to the effect.

Anyway, sorry for going OT... but wow, that was trippy.

And yeah, you need to HASH (#...#) your CF variables within your
CFQUERY blocks. That should be all you need to do, the rest of your
query's fine. You DO need to remove the hashes from your assignment
operations, though. Bad formation, even though it works.

<cfset newMonth = Month(DateAdd("n", 1, Now()))>
<cfset newDay = Day(DateAdd("n", 1, Now()))>
<cfset newYear = Year(DateAdd("n", 1, Now()))>

<cfquery name="GetClosings" Datasource="#Application.Speck.Codb#">
  Select s.CorpNumber, s.UserID, s.EffectiveDate, s.ReportedDateTime,
s.Closed, i.name as CorpName
  From status s, sites i
  Where s.corpNumber = i.id and
         Month(s.EffectiveDate) = #variables.newMonth# and
         Day(s.EffectiveDate) = #variables.newDay# and
        Year(s.effectiveDate) = #variables.newYear# and
         s.closed = 1
    Order by CorpName
</cfquery>

I've also taken to using the following format for addressing scoped variables:
variables["newMonth"]

Why? Because it's more flexible in general to use this notation, and
doing it most of the time keeps the habit fresh. There are areas where
you simply CANNOT use that notation (like assigning an sproc resultset
to a var'ed struct) and have to use dotted notation. But using the
container["var"] syntax makes it possible to use a variable with a
string as the second value:
if colName = "user_id" then variables[colName] resolves to
variables["user_id"]. VERY handy way to use this. It also works for
queries using the queryName["colName'][rowIndex] syntax for accessing
query data.

I hope this helps.

Laterz!

J
On Sun, 6 Mar 2005 22:34:57 -0000, Adrian Lynch
<[EMAIL PROTECTED]> wrote:
> Put hashes(pound signs) around your variables:
> 
> Day(Status.EffectiveDate) = #variables.newDay# and
> 
> without them the SQL reads as is e.g. a table named variables with a column
> named newDay.
> 
> Ade
> 
> 


-- 
Continuum Media Group LLC
Burnsville, MN 55337
http://www.web-relevant.com
http://cfobjective.neo.servequake.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:197720
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to