• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

<cfreturn>

Explorer ,
Dec 11, 2006 Dec 11, 2006

Copy link to clipboard

Copied

Is it possible to return multiple variables from a <cffunction> using <cfinvoke>. I understand I can use a struct, but I am looking for a way to return multiple stand-alone variables.
TOPICS
Advanced techniques

Views

420

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 11, 2006 Dec 11, 2006

Copy link to clipboard

Copied

Is it possible to return multiple variables from a <cffunction> using
<cfinvoke>. I understand I can use a struct, but I am looking for a way
to return multiple stand-alone variables.


You can not return multiple values from a function without using a
structure to combine them. You can have the function set variables
outside the function in the calling scope or higher, but most developers
would consider this to be very poor design.

Something against structures? They are very handy things.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 11, 2006 Dec 11, 2006

Copy link to clipboard

Copied

I am new to creating web services, and noticed that the samples I have looked at have multiple output variables, which makes grabbing the right piece of data a snap. I was interested in trying to create this kind of thing with a .cfc. No problem using a struct, but the app I am using to consume the web service doesn't give me much flexibility in parsing the struct. Thanks for you insights.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 12, 2006 Dec 12, 2006

Copy link to clipboard

Copied

> I am new to creating web services, and noticed that the samples I have looked
> at have multiple output variables,

Can you post an example of that?

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 13, 2006 Dec 13, 2006

Copy link to clipboard

Copied

OK, I modified my web service get7.cfc?wsdl to return a structure with 3 elements representing the 3 columns in my table. You can view a <cfdump> of the service at get7.cfm

The code for my cfc is attached.

The web service works fine, but fails when I try to consume it with my dashboard. I am creating a dashboard with Crystal Xcelsius, so I realize it is basically an Xcelsius issue, but any tips would be appreciated. I have successfully created and consumed (with Xcelcius) web services that return a single string variable, but can't get it to work with 2 dimensional (repeating) elements (ie query data). Please take a look at my cfc code and see what you think.

Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 13, 2006 Dec 13, 2006

Copy link to clipboard

Copied

LATEST
Add a function to your cfc that produces a simple 2D array. If you are able to consume that with Xcelsius, then create an array instead of a function with your real function. If not, try xml.

As an aside, it's a good idea to use the var keyword in your function to create every variable, including the query. This keeps the variable names local to the function and prevents mysterious problems in the programs that use them.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation