Re: [cfwheels] I would like to use a microsoft stored procedure i.e. a mixture of orm and stored procedures for complex actions

25 views
Skip to first unread message

Andy Bellenie

unread,
Apr 26, 2013, 6:47:11 PM4/26/13
to ColdFusion on Wheels
You can also do that in Wheels, ideally place the function inside a model.


On 26 April 2013 22:31, <sz...@coastline.edu> wrote:
in coldfusion I used to do something like that

<cffunction name="cfn_SectionDropBox_GradedbyDropBoxID"  
                    output="yes" 
                    access="remote"
                    RETURNTYPE="query"> 
                    
          <cfargument name="DropBoxID"    type="numeric" required="yes" > 
          <cfargument name="SectionID"    type="numeric" required="yes" > 
          
                   <cfstoredproc  
                                procedure="dbo.usp_SectionDropBox_GradedbyDropBoxID" 
                                datasource="#application.dsn#" > 
                                
                    
                   <cfprocparam value="#arguments.DropBoxID#" 
                                    type="in"
                                    cfsqltype="cf_sql_integer"
                                    null="no">
                     <cfprocparam value="#arguments.SectionID#" 
                                    type="in"
                                    cfsqltype="cf_sql_integer"
                                    null="no">
                                                                   
        <cfprocresult name = "RS_SectionDropBox_GradedbyDropBoxID" > 
      
      </cfstoredproc> 
               
   
           
<cfreturn RS_SectionDropBox_GradedbyDropBoxID> 
     </cffunction>
            




--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+u...@googlegroups.com.
To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at http://groups.google.com/group/cfwheels?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

sz...@coastline.edu

unread,
Apr 28, 2013, 8:30:37 PM4/28/13
to cfwh...@googlegroups.com

sz...@coastline.edu

unread,
Apr 28, 2013, 8:31:26 PM4/28/13
to cfwh...@googlegroups.com
Can you give an example.
Shall I use cfarguments 
How to call this function with cfarguments.
Thanks

sz...@coastline.edu

unread,
Apr 28, 2013, 8:50:45 PM4/28/13
to cfwh...@googlegroups.com
I.e. I read your topic 

Put the function in your model

<cffunction name="foo" returntype="query" output="false"> 
        <cfset var spQuery = ""> 
        <cfstoredproc datasource="#variables.wheels.class.connection.datasource#" 
result="spQuery"> 
        <cfreturn spQuery> 
</cffunction> 

To call your function

<cfset page = model("page").your function name(your arguments)>
<cfset page = model("page").get(params.key)>.

but can you give me example of the page in the view folder how it looks like.

Thanks a lot

Tom King

unread,
Apr 29, 2013, 3:00:24 AM4/29/13
to cfwh...@googlegroups.com
A function in a model would not have a view page.
You might call it in a view, but more likely, it would be called by a controller function.

i.e

<cffunction name="index">
<cfset mymodel=model("mymodel").findOne(where="foo = 1")>
<cfset customQuery  = mymodel.customFunction(argument1 = "foo", argument2 = "bar")>
</cffunction>
Reply all
Reply to author
Forward
0 new messages