Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7725073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:50:52+00:00 2026-06-01T04:50:52+00:00

I am trying to convert some pages from my app to use cfc’s, and

  • 0

I am trying to convert some pages from my app to use cfc’s, and one page uses a stored procedure to retrieve a couple sets of data.

Now when I access the results, they act just like a if I used a <cfquery> tag, and all of the functionality that gives. So now I am trying to use this same stored procedure in a cfc that I am building, and I would like to be able access the results in the same manner, and there in lies my problem. I’m not sure how to return multiple queries from the function, without creating an array, which I have started. By the way, the function is incomplete. I was just trying to get something to work. In the below setup I get an array of query objects, but I feel there is a better way to do it.

Here is the <cffuntion>:

<cffunction name="getProfileData" 
            access="public" 
            output="false" 
            returntype="string">

    <cfargument name="cusip" type="string" required="true">
    <cfargument name="report_date" type="date" required="true">
    <cfset var errorMessage = "everything is good">

    <cftry>
        <cfstoredproc datasource="#dsn#" procedure="prc_asset_profile_retrieve">
            <cfprocparam type="in" cfsqltype="cf_sql_varchar" value="#cusip#" dbvarname="@cusip">
            <cfprocparam type="in" cfsqltype="cf_sql_varchar" value="#report_date#" dbvarname="@reportDate">
            <cfprocresult name="profile_head" resultset="1">
            <cfprocresult name="attribution" resultset="2">
            <cfprocresult name="characteristics" resultset="3">
            <cfprocresult name="exposure" resultset="4">
            <cfprocresult name="weights" resultset="5">
            <cfprocresult name="holdings" resultset="6">
        </cfstoredproc>

        <cfset var profileArray = []>
        <cfset #ArrayAppend(profileArray,profile_head)#>

        <cfcatch type="any">
            <cfset errorMessage = "something happened">
        </cfcatch>          
    </cftry>

    <cfreturn profileArray>
</cffunction>

When I output some test data, it matches up

<cfset count = fund_profile.getProfileData("#cusip#","#report_date#")> 
<cfdump var="#count[1]#">
<cfoutput>
    From cfc (##count[1].recordCount##): #count[1].recordCount#<br>
    From stored proc (##profile_head.recordCount##): #profile_head.recordCount#
</cfoutput>

I get:

From cfc (#count[1].recordCount#): 1
From stored proc (#profile_head.recordCount#): 1

But the second way looks so much cleaner.

   -----------------------------WORKING SOLUTION------------------------------ 

So after working with the answer from @leigh, I came up with this.

Here is the full cfc:

<cfcomponent displayname="Fund Profile" hint="This is the cfc that will do the processing of all fund profile information" output="false">
     <cfproperty name = "result1"> <!--- PROFILE HEAD --->
     <cfproperty name = "result2"> <!--- ATTRIBUTION --->
     <cfproperty name = "result3"> <!--- CHARACTERISTICS --->
     <cfproperty name = "result4"> <!--- EXPOSURE --->
     <cfproperty name = "result5"> <!--- WEIGHTS --->
     <cfproperty name = "result6"> <!--- HOLDINGS --->

     <cffunction name="init" 
            displayname="init" 
            hint="This will initialize the object" 
            access="public" 
            output="false" 
            returnType="Any">

        <cfargument name="dsn"  type="string" required="true" />
        <cfargument name="cusip" type="string" required="true" />
        <cfargument name="report_date" type="date" required="true" />

        <cfset variables.dsn = #arguments.dsn#>
        <cfset variables.cusip = #arguments.cusip#>
        <cfset variables.report_date = #arguments.report_date#>

        <cfscript>
            getProfiledata(cusip,report_date);
        </cfscript>     

        <cfreturn this>
    </cffunction>

    <cffunction name="getProfileData" 
            access="private" 
            output="false" 
            returntype="void">

        <cfargument name="cusip" type="string" required="true">
        <cfargument name="report_date" type="date" required="true">

        <cfstoredproc datasource="#dsn#" procedure="prc_asset_profile_retrieve">
             <!--- STORED PROCEDURE HASN'T CHANGED.  SEE ABOVE FOR CODE --->
        </cfstoredproc>

        <cfscript>
            setProfilehead(profile_head);
            setAttribution(attribution);
            setCharacteristics(characteristics);
            setExposure(exposure);
            setWeights(weights);
            setHoldings(holdings);
        </cfscript>

        <cfreturn>
    </cffunction>

    <!--- NOT GOING TO INCLUDE ALL SETTERS AND GETTERS, --->
    <!--- BECAUSE THEY ARE ALL THE SAME OTHER THAN THE NAMES --->

    <cffunction name="setProfileHead" access="private">
        <cfargument name="ProfileHead">
        <cfset variables.result1 = arguments.ProfileHead>       
    </cffunction>

    <cffunction name="getProfileHead" access="public" returntype="query">
        <cfreturn variables.result1>
    </cffunction>

</cfcomponent>

Here is the code from the calling page:

<cfset fund_profile = CreateObject("component", "CFCs.fund_profile").init("#dsn#","#cusip#","#report_date#")>
<cfset profile_head = fund_profile.getProfileHead()>

Sorry for all the code, but I wanted to make the code available. So does anyone see any problems with what I came up with?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:50:53+00:00Added an answer on June 1, 2026 at 4:50 am

    I would create other methods in the CFC that would each be responsible for returning a result from the stored proc. In the main method , call setters
    setProfileHead(profilehead:profileHead)

    <cffunction name=ProfileHead>
        <cfarguments name=ProfileHead />
        <cfset variables.profilehead = arguments.profilehead>
     </cffunction>
    

    Then…

    <cffunction name=GetProfileHead>
        <cfreturn variables.profileHead />
    </cffuction>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert some code from Richfaces 4 showcase to use CDI instead
I am getting some problems after trying to convert my android app to use
Background : I'm trying to convert some JavaScript code which uses the the Crossfilter
There is some code that I'm trying to convert from IList to IEnumerable :
I'm trying to use the Macromedia XSLTransform class to convert XML returned from Amazon
I'm trying to use gson to convert this returned JSON into some kind of
I'm trying to convert some simple .htaccess rewrites into web.config xml; all is well
I am trying to convert some pre-existing html/JavaScript files to Flex. I tried making
I'm trying to convert some VB.net code into C# and having issues trying to
I am trying to convert some ExtJS 3.3 to 4.0. In ExtJS 3.x I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.