An open question then...
I have a function that takes optional arguments for each of the columns in a
table like this:
<cffunction name="create">
<cfset var separator = "">
<cfset var q = "">
<cfquery name="q" datasource="#VARIABLES.DSN#">
INSERT INTO [comment] (
<cfif StructKeyExists(ARGUMENTS, "column1")>
#separator#
[column1]
<cfset separator = ",">
</cfif>
<cfif StructKeyExists(ARGUMENTS, "column2")>
#separator#
[column2]
<cfset separator = ",">
</cfif>
) VALUES (
<cfset separator = "">
<cfif StructKeyExists(ARGUMENTS, "column1")>
#column1#
<cfqueryparam cfsqltype="CF_SQL_INTEGER"
value="#ARGUMENTS.column1#">
<cfset separator = ",">
</cfif>
<cfif StructKeyExists(ARGUMENTS, "column2")>
#separator#
<cfqueryparam cfsqltype="CF_SQL_INTEGER"
value="#ARGUMENTS.column2#">
<cfset separator = ",">
</cfif>
)
SELECT SCOPE_IDENTITY() [commentID]
</cfquery>
<cfreturn q.commentID>
</cffunction>
This allows me to do an insert with any combination of columns using named
arguments:
<cfset myDOA.create(column1 = 123)>
<cfset myDOA.create(column2 = 321)>
<cfset myDOA.create(column1 = 123, column2 = 321)>
I have similar ones for updating, selecting and deleting.
So, how best to replicate this using stored procedures?
The place I'm working at the moment won't allow cfquery so I can't use my
beautiful code generator :O(
Adrian
Building a database of ColdFusion errors at http://cferror.org/
-----Original Message-----
From: Craigsell
Sent: 30 October 2008 17:45
To: cf-talk
Subject: Re: cfqueryparam vs cfstoredproc?
My 2 cents....
I use ORACLE stored procs exclusively (using a CFSTOREDPROC tag) and have
found them to be great. There are things I can do in stored procs that
would be difficult to do in a CFC. I can easily have multiple datasets
returned in one call. And the CFPROCPARAM gives me the same benefits as
CFQUERYPARAM.
I'm a big believer in doing database things on the database and display
stuff in the web server. I'll confess though that I don't use CF much
anymore except for CFCs-- most everything I do is in Flex.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314622
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4