If you don't want to do cfqueryparam, use the SQL version. The SQL version 
works well if you want to put the query in a folded string that can be 
passed to a function that does the cfquery.  Data binding is done either 
way.  In all cases, I think doing the data binding declaration is a best 
practice technique.

Data binding without cfqueryparam:

<cfquery>
DECLARE @ID int
SET @ID = 324
-- or use CF variable to as SET @ID = #Variables.ID#
  select emp.name, emp.salary
  from emp
  where emp.id = @ID
  </cfquery>

  or folded string technique:

  <cffunction name="runQuery" returntype="query">
         <cfset var QueryReturn = "" >
          <cfquery name="QueryReturn">
                 #PreserveSingleQuotes(Arguments[1])#
         </cfquery>
         <cfreturn QueryReturn >
  </cffunction>

  <cfset Variables.ID = 324 >
  <cfsavecontent variable="myQueryString">
          DECLARE @ID int
            SET @ID = #Variables.ID#
                        select emp.name, emp.salary
                  from emp
                  where emp.id = @ID
   </cfsavecontent>
   <cfset qResult = runQuery(myQueryString) >

In these approaches, the data binding occurs when the query is submitted.

( In the testing I did to determine the best approach for the code that 
CFSQLTool generates, I found that using <cfqueryparam> provides better 
debug and support options rather than doing the folded string. )

Joseph


At 05:33 PM 7/5/2005, you wrote:
>When I posed this question to the group some time ago, the consensus was 
>basically your point, but the one counter point the struck me was, "well 
>it's not a variable now, but might it become one in the future?"  So, 
>depends on how malleable you feel the code may be over its lifetime.
>

http://www.switch-box.org/CFSQLTool/Download/

Switch_box                      MediaFirm, Inc.
www.Switch-box.org              Loveland, CO  USA


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:211305
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