473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

function [returning more than one value]

Hello,
As we know function returns only one value, i had one doubt here that if we have out parameter in function can it return more than one.....
please let me know
Jun 18 '07 #1
7 5484
TRScheel
638 Expert 512MB
Hello,
As we know function returns only one value, i had one doubt here that if we have out parameter in function can it return more than one.....
please let me know
What language are you using?
Jun 18 '07 #2
bartonc
6,596 Expert 4TB
Hello,
As we know function returns only one value, i had one doubt here that if we have out parameter in function can it return more than one.....
please let me know
Hi Syed. I've moved you post to Miscellaneous Questions. If you tell us the programming language that you are using, you'll be able to get answers from experts in that language.

From my understanding of C, for example, output parameters are a way to force "pass by reference". Which means that you can alter the value of a variable outside the function because a pointer is actually passed into the function instead of the value.

In Python, on the other hand, you can specify any number of variables on the return line and the interpreter packs them into a structure called a "tuple".

Hope that helps.
Jun 18 '07 #3
debasisdas
8,127 Expert 4TB
if you are using Oracle PL/SQL then you can do it.
Jul 12 '07 #4
debasisdas
8,127 Expert 4TB
If uare using oracle PL/SQL to write functions then that is possible

Using the RETURN clause, function can return only one variable. The variable can be of any data type - Number, VARCHAR, REF CURSOR, PL/SQL Table and many more. If the function is returning a data structure like PL/SQL Table, REF CURSOR etc, it is returning more than one value.

Another way of returning values is using OUT parameters. And this applies to both Procedures and Functions. Using OUT parameters, you can return as many values as you need.

If you have a need for OUT parameters, though, you would generally want a procedure, not a function. A function with OUT parameters cannot be called from a SQL statement, which rather defeats the purpose of using a function.


Function can able to return more than one value using ref cursur...

but that is not recomended.
Jul 12 '07 #5
Hi,

I don't know if it helps but here is a sample that returns a table. This way you can get multiple values (link ).

Greetz,

Geert
Jul 24 '07 #6
kmm
3
Hello,
As we know function returns only one value, i had one doubt here that if we have out parameter in function can it return more than one.....
please let me know
i think a function always return only a single value whtever the no. of parameters it may be
Jul 24 '07 #7
TRScheel
638 Expert 512MB
In .NET it is perfectly acceptable to return multiple parameters.

Expand|Select|Wrap|Line Numbers
  1. interface IInterface
  2. {
  3.     private bool MyFunction(out object Parameter1, out object Parameter2, out object Parameter3);
  4. }
  5.  
That function returns a bool, and has 3 parameters set to out.


Using c++ without .NET, you could set as many parameters as you want but they must be sent to the function by reference.
Jul 24 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people...
2
by: sean | last post by:
HI, I would like to know if I can some set a variable to return a single value from a function using the set command. Is this possible? Thanks in advance for your answer Sean
41
by: Materialised | last post by:
I am writing a simple function to initialise 3 variables to pesudo random numbers. I have a function which is as follows int randomise( int x, int y, intz) { srand((unsigned)time(NULL)); x...
14
by: Stegano | last post by:
I am learning C Programming after working with Java for 5 years. I want to know where can I find the source files for C language itself. For example strcat is a function, which concatenates two...
27
by: Marlene Stebbins | last post by:
I am experimenting with function pointers. Unfortunately, my C book has nothing on function pointers as function parameters. I want to pass a pointer to ff() to f() with the result that f() prints...
8
by: ais523 | last post by:
I use this function that I wrote for inputting strings. It's meant to return a pointer to mallocated memory holding one input string, or 0 on error. (Personally, I prefer to use 0 to NULL when...
17
by: I.M. !Knuth | last post by:
Hi. I'm more-or-less a C newbie. I thought I had pointers under control until I started goofing around with this: ...
11
by: aarklon | last post by:
Hi all, I have heard many discussions among my colleagues that main is a user defined function or not. arguments in favour:- 1) if it is built in function it must be defined in some header...
26
by: aruna.mysore | last post by:
Hi all, I have a specific problem passing a function pointer array as a parameter to a function. I am trying to use a function which takes a function pointer array as an argument. I am too sure...
160
by: DiAvOl | last post by:
Hello everyone, Please take a look at the following code: #include <stdio.h> typedef struct person { char name; int age; } Person;
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.