Geoff,

What you're doing is learning the syntax of the language and wondering what
is the best practice.  I'm in the same boat as you are.

If I had time, I would study other people's code like Ray Camden's blogcfc,
and I would take time to look into frameworks such as Fusebox and Model Glue
to see how they do cfcs.

What you want to do is encapsulate your ideas.  "This goes in, this comes
out".  Use the hint keyword when defining your function.  If it starts to
feel like a run-on sentence, that might be an indication that it's doing too
much.

Prove that your function is consistent with others by showing an example of
some other language function that returns three resultsets. 




-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Geoff Parkhurst
Sent: Tuesday, April 11, 2006 6:12 AM
To: [email protected]
Subject: [CFCDev] Multiple stored proc resultsets

I have a stored proc which returns 3 different resultsets as follows:

<cfstoredproc datasource="#application.ds#" procedure="someproc">
        <cfprocparam dbvarname="prodid" value="#val(somevalue)#"
cfsqltype="cf_sql_integer" type="in"/>
        <cfprocresult name="variables.prodinfo" resultset="1"/>
        <cfprocresult name="variables.relatedprods" resultset="2"/>
        <cfprocresult name="variables.images" resultset="3"/>
</cfstoredproc>

I would like to stick this in a CFC, but I'm not sure what my returntype
should be...

Would this be suitable:

<cffunction name="productdetails" access="public" returntype="struct">
        <cfargument name="somevalue" type="numeric" required="yes"/>
        <cfset var something=structnew()/>

        <!--- test arguments.somevalue a bit more to see if it's a positive
integer etc --->

        <cfstoredproc datasource="#variables.ds#" procedure="someproc">
                <cfprocparam dbvarname="prodid"
value="#arguments.somevalue#" cfsqltype="cf_sql_integer" type="in"/>
                <cfprocresult name="something.prodinfo" resultset="1"/>
                <cfprocresult name="something.relatedprods" resultset="2"/>
                <cfprocresult name="something.images" resultset="3"/>
        </cfstoredproc>
        <cfreturn something/>
</cffunction>

I don't really know if this stored proc is faster than 3 individual
queries... I have a nagging feeling I should really have three cffunctions,
each responsible for returning a query on their own to keep things discreet
and modular, but I'm not sure.

Any thoughts greatly appreciated.
Cheers,
Geoff




----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]




----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to