0

I want to return multiple values FROM ORACLE FUNCTION to fill the drop-down list box in front end and values are database constants of package.

I have tried this function:

return varchar2
IS

BEGIN

return  pr_package.constant1_string;

return pr_package.constant2_string;

  end;

I need a help as soon as possible, suggestions are welcome. Thanks in advance.

1 Answer 1

1

You can't have multiple returns from a function.

You could return a collection from a function. Something like

CREATE TYPE string_array
    IS TABLE OF VARCHAR2(100);

CREATE OR REPLACE FUNCTION return_string_array
   RETURN string_array
IS
  l_string_array string_array := new string_array( pr_package.constant1_string, 
                                                   pr_package.constant2_string );
BEGIN
  RETURN l_string_array;
END;

Or you can create a pipelined table function. Using the same type, you can then pipe multiple rows

  1  create or replace function pipeline_test
  2   return string_array
  3   pipelined
  4  is
  5  begin
  6    pipe row( 'Foo' );
  7    pipe row( 'Bar' );
  8    return;
  9* end;
SQL> /

Function created.

SQL> select * from table( pipeline_test );

COLUMN_VALUE
--------------------------------------------------------------------------------
Foo
Bar
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.