Was mucking about trying to optomise a reports template and noticed I had the 
following code  (obvious dynamic variables)...

<cfquery name="qIF_GetQuestion" datasource="#APPLICATION.sIF_DSN#">
        SELECT #sColName# AS QUESTION
        FROM    #sTableName#
        WHERE   #sPKCol# = <cfqueryparam value="#iIF_ElementID#" 
cfsqltype="CF_SQL_DECIMAL">
</cfquery>


Lead webdev suggested trying cfqueryparam's like so....

<cfquery name="qIF_GetQuestion" datasource="#APPLICATION.sIF_DSN#">
        SELECT <cfqueryparam value="#sColName#" cfsqltype="CF_SQL_VARCHAR"> AS QUESTION
        FROM    <cfqueryparam value="#sTableName#" cfsqltype="CF_SQL_VARCHAR">
        WHERE   <cfqueryparam value="#sPKCol#" cfsqltype="CF_SQL_VARCHAR"> = 
<cfqueryparam value="#iIF_ElementID#" cfsqltype="CF_SQL_DECIMAL">
</cfquery>


The above gave an error of Database table not found.... (dynamic table name given is 
correct though)
When I take the cfqueryparam out ot the TABLE bit so it looks like this... it works!!!


<cfquery name="qIF_GetQuestion" datasource="#APPLICATION.sIF_DSN#">
        SELECT  <cfqueryparam value="#sColName#" cfsqltype="CF_SQL_VARCHAR"> AS 
QUESTION
        FROM            <cfqueryparam value="#sTableName#" cfsqltype="CF_SQL_VARCHAR">
        WHERE   <cfqueryparam value="#sPKCol#" cfsqltype="CF_SQL_VARCHAR"> = 
<cfqueryparam value="#iIF_ElementID#" cfsqltype="CF_SQL_DECIMAL">
</cfquery>


Not actually looked at if there has been any major performance increase cause of this 
but can anybody explain why it doesn't accpet it in the FROM clause, but it does in 
the SELECT or WHERE?

cheers,

DC
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to