function [returning more than one value]

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Syed Zaheer Ulla
    New Member
    • Jun 2007
    • 1

    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
  • TRScheel
    Recognized Expert Contributor
    • Apr 2007
    • 638

    #2
    Originally posted by Syed Zaheer Ulla
    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?

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #3
      Originally posted by Syed Zaheer Ulla
      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.

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        if you are using Oracle PL/SQL then you can do it.

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          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.

          Comment

          • GeertVerhoeven
            New Member
            • Jul 2007
            • 1

            #6
            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

            Comment

            • kmm
              New Member
              • Jul 2007
              • 3

              #7
              Originally posted by Syed Zaheer Ulla
              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

              Comment

              • TRScheel
                Recognized Expert Contributor
                • Apr 2007
                • 638

                #8
                In .NET it is perfectly acceptable to return multiple parameters.

                [code=cpp]
                interface IInterface
                {
                private bool MyFunction(out object Parameter1, out object Parameter2, out object Parameter3);
                }
                [/code]

                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.

                Comment

                Working...