Why not just pass the fields you want to return data as an argument. 

>I like the 1st way, as it allows you to have 1 query that returns different
>things based on the arguments (which are set to optional).  
>
>If you really don't want to return more data then needed, you can do this
>
><cfargument name="repaircenter" type="numeric" required="no" default="0">
>
><cfset var qRepairCenter="">
>
><CFQUERY name="qRepairCenter" datasource="#Variables.DSN#">
>       SELECT centerId <cfif arguments.repaircenter>, center</cfif>
>       FROM Repaircenters
>       <cfif arguments.repairCenter>
>          WHERE center=<cfqueryparam value="#Arguments.RepairCenter#" 
>cfsqltype="CF_SQL_VARCHAR">
>       </cfif>
>       ORDER BY center
></CFQUERY>
>-----Original Message-----
>From: Michael Dinowitz [mailto:[EMAIL PROTECTED] 
>Sent: Sunday, December 18, 2005 2:11 PM
>To: CF-Talk
>Subject: Re: CFC Function Style
>
>Using the third style, the first SQL is looking for a single piece of data 
>(an int) while the second SQL is looking for 2 (and int and a varchar). The 
>first is also using a param where the second doesn't have one. I just don't 
>like returning more data than is needed.
><CFQUERY name="qRepairCenter" datasource="#Variables.DSN#">
><CFIF StructKeyExists(arguments, 'repaircenter')>
>   Select centerid
>   from Repaircenters
>    where center=<cfqueryparam value="#Arguments.RepairCenter#" 
>cfsqltype="CF_SQL_VARCHAR">
><CFELSE>
>   Select centerid, center
>   from Repaircenters
>   order by center
></CFIF>
></CFQUERY>
>
>Using the first option, it would look like this:
><CFQUERY name="qRepairCenter" datasource="#Variables.DSN#">
><CFIF StructKeyExists(arguments, 'repaircenter')>
>   Select centerid
><CFELSE>
>   Select centerid, center
></CFIF>
>   from Repaircenters
><CFIF StructKeyExists(arguments, 'repaircenter')>
>    where center=<cfqueryparam value="#Arguments.RepairCenter#" 
>cfsqltype="CF_SQL_VARCHAR">
></CFIF>
>   order by center
></CFQUERY>
>Two different CFIF statements to control the two different changes.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

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