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.

> Just recently I did the first option and it was more from the stand point 
> of
> I did not see any value to having a separate function for each need like
> this.  Seems like there is not a huge difference between the 1st and 3rd,
> both use a CFIF to decide how the output of the function is going to be.
> One just takes the route of doing a different query for the IF and the 
> ELSE
> then the other just uses one single query that then has the IF/ELSE work
> done within it.  Or am I reading the first option incorrectly?  In the 
> past
> I did option two almost exclusively but when I was evaluating that path
> recently I decided I was ending up with quite a few functions that were 
> more
> or less very similar to one another so some could be combined into one
> function with just some minor IF/ELSE logic.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:227250
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