I did something similar to the 1st then with the exception of I did not do a check to see if the argument existed. I had two arguments one being "ID" and the other "LEVEL" Both required but with a default set to the "LEVEL" So I would then do a check to see if Arguments.LEVEL NEQ "whatever the default value was" I also was selecting a couple of columns that were the same either way so it was along the lines of: SELECT ID, NAME <cfif Arguments.LEVEL NEQ "whatever the default value was">, some other columns</cfif>
In my case I was trying to reuse the base query itself which is probably why I leaned to putting in a IF statement within my SELECT clause and I believe I had one in the FROM but no way to reference the code from where I am at right now. Had I not been set on the direction of reusing the base query I probably would have done the third style. Sometimes I have done it with multiple functions, one would be a base query and then the other functions would be QoQ onto that first functions results. On 12/18/05, Michael Dinowitz <[EMAIL PROTECTED]> wrote: > > 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. > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| 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:227253 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

