How can a function retun more than one value in oracle with proper example?



How can a function retun more than one value in oracle with proper example?..

Answer / Shalini Pathak

In Oracle PL/SQL, a function cannot return multiple values directly. However, you can use collections (such as arrays or tables) to return multiple values. Here's an example of a table-valued function that returns a table of employee names:

CREATE OR REPLACE TYPE employees_table AS TABLE OF VARCHAR2(30);

CREATE OR REPLACE FUNCTION get_employees RETURN employees_table IS
v_employees employees_table;
BEGIN
SELECT employee_name BULK COLLECT INTO v_employees FROM employees;
RETURN v_employees;
END;

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

Authentication mechanisms in Sql Server ?

1 Answers   BirlaSoft,


How do you take the union of two tables in sql?

1 Answers  


What are some emotional triggers?

1 Answers  


Does varchar need length?

1 Answers  


How do you optimize a query?

1 Answers  


hi sql gurus, here is my question 4 u. i wanna use triggers for sending reminder mail to all users who are registered to the site. if any one knws the code plz send me ans here : chayabs3@gmail.com thnx advance

1 Answers  


What is the difference between clustered and non-clustered index in sql?

1 Answers  


how can I make a script that can be bi-language (supports english, german)? : Sql dba

1 Answers  


What are the dml statements?

1 Answers  


How can you maintain the integrity of your database on instances where deleting an element in a table result in the deletion of the element(s) within another table?

1 Answers  


How to make a copy values from one column to another in sql?

1 Answers  


What is string data type in sql?

1 Answers  


Categories