I'm trying to optimize some queries and I've got a dumb question. The
current code is like this:
<!--- Check to see if the key exists ---> <cfquery ... >
SELECT SessionKey
FROM Table
WHERE SessionKey = <cfqueryparam ... >
</cfquery>
<!--- If it's a new entry, create it, if not update it ---> <cfif
local.CheckEntry.RecordCount EQ 0>
<!--- Add the Session information --->
<cfquery ... >
INSERT INTO Table ( SessionKey )
VALUES ( <cfqueryparam ... > )
</cfquery>
<cfelse>
<cfquery ... >
UPDATE Table
SET SessionKey = <cfqueryparam ... >
</cfquery>
</cfif>
What I'm going to do (this is SQL Server 2000) is replace that with an
"exists" test in a single query like so:
<!--- Check to see if the key exists ---> <cfquery ... >
IF EXISTS (
SELECT SessionKey
FROM Table
WHERE SessionKey = <cfqueryparam ... >
)
BEGIN
INSERT INTO Table ( SessionKey )
VALUES ( <cfqueryparam ... > )
END
ELSE
BEGIN
UPDATE Table
SET SessionKey = <cfqueryparam ... >
END
</cfquery>
My question is with <CFPARAM> - what's up in this case? Will it work fine
when all of the parameters all nested in IF statements like this? Will
there just be a big long list of BIND variables and will the statement
(INSERT or RUN) use the right ones?
Am I making any sense?
Jim Davis
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - CFDynamics
http://www.cfdynamics.com
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188846
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