adspace


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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the best sql course?

1050


what are the advantages of sql ? : Sql dba

1142


how to use regular expression in pattern match conditions? : Sql dba

1113


Can delete statement be rollbacked?

1054


Is inner join faster than left join?

1277


Does group by remove duplicates?

1112


What is the current version of postgresql?

1178


what are all the common sql function? : Sql dba

1131


Is primary key always clustered index?

1095


What is your daily office routine?

2346


what is sql server agent? : Sql dba

1182


Can we use distinct and group by together?

1133


If a cursor is open, how can we find in a pl/sql block?

1238


Can we rollback truncate?

1074


Do we need to rebuild index after truncate?

1138