Just for fun then if you have a mix of constants and variables would it be
written like this?


SELECT *
FROM table
WHERE status = 'A'
    AND ID = <cfqueryParam value="1246" ...>


or


SELECT *
FROM table
WHERE status = <cfqueryParam value="A" ...>
    AND ID = <cfqueryParam value="1246 ...>


I would think the former from the answers in this forum, but I'm not sure.
Or are they both the same really, and it doesn't matter?

--------------
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA

-----Original Message-----
From: Shawn McKee [mailto:[EMAIL PROTECTED]
Sent: Monday, December 08, 2003 11:29 AM
To: CF-Talk
Subject: RE: The Value of CFQUERYPARAM

I just talked to my Oracle DBA and if the query is all constants

SELECT M
FROM S
WHERE W = 'huh'

it will get parsed once and put in the cache.

SELECT M
FROM S
WHERE W = '#url.k#'

Gets parsed  every time the contents of url.k changes

SELECT M
FROM S
WHERE W = ?

? = 'huh'
Is the solution for this because the QUERYPARAM is a bind variable that the
DB can handle and knows no to parse again.

Shawn McKee

-----Original Message-----
From: Tom Kitta [mailto:[EMAIL PROTECTED]
Sent: Monday, December 08, 2003 12:58 PM
To: CF-Talk
Subject: RE: The Value of CFQUERYPARAM

As far as I know, yes, it does recompile every time. And it is quite
intuitive, just look at the debug of what is sent to the DB server for
something like:

SELECT M
FROM S
WHERE W = '#url.k#'

and

SELECT M
FROM S
WHERE W = 'huh'

Assuming url.k is 'huh' you get the same thing sent to the DB server.
However, if you use cfqueryparam what is sent:

SELECT M
FROM S
WHERE W = ?

? = 'huh'

So the DB compiles (only once) the query and puts in 'huh' as the argument.
Summarizing it doesn't matter whatever 'huh' is static or from a variable,
it is still treated the same way. Also, it would help to remember that
#your_var_here# causes the value of the var to be printed and it becomes
static text.

TK

  -----Original Message-----
  From: Ian Skinner [mailto:[EMAIL PROTECTED]
  Sent: Monday, December 08, 2003 1:47 PM
  To: CF-Talk
  Subject: RE: The Value of CFQUERYPARAM

  Even though the value is static and unchanging, the query will be
recompiled
  every time?  This seems to be a bit counter intuitive to me, but it is
  basically what I'm trying to confirm.

  --------------
  Ian Skinner
  Web Programmer
  BloodSource
  www.BloodSource.org
  Sacramento, CA

  -----Original Message-----
  From: Tom Kitta [mailto:[EMAIL PROTECTED]
  Sent: Monday, December 08, 2003 10:43 AM
  To: CF-Talk
  Subject: RE: The Value of CFQUERYPARAM

  Use CFQUERYPARAM as the DB engine will only compile you query once and
  hopefully cache it. Otherwise it will re-compile every time.

  TK
    -----Original Message-----
    From: Ian Skinner [mailto:[EMAIL PROTECTED]
    Sent: Monday, December 08, 2003 1:36 PM
    To: CF-Talk
    Subject: The Value of CFQUERYPARAM

    When writing a select statement, if I have a part of a WHERE clause that
    will be static, always the same value, and this value is not passed in
  with
    a variable or constant, is there any inherent value in <cfqueryParam
...>
    tags?

    An Example:

    WHERE STATUS = <cfqueryParam value="M" ...>

    or

    WHERE STATUS = 'M'

    Is there any real advantage of one of these forms over the other?

    Just to repeat, these are hard coded, unchanging values NOT passed in
with
    variables or constants.  I understand the value of the <cfqueryParam>
tags
    in conjunction with passing in data with variables, especially data from
    user forms.

    --------------
    Ian Skinner
    Web Programmer
    BloodSource
    www.BloodSource.org
    Sacramento, CA

    Confidentiality Notice:  This message including any
    attachments is for the sole use of the intended
    recipient(s) and may contain confidential and privileged
    information. Any unauthorized review, use, disclosure or
    distribution is prohibited. If you are not the
    intended recipient, please contact the sender and
    delete any copies of this message.
     _____
  _____
   _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to