I have my package header:
CREATE OR REPLACE PACKAGE my_package is
TYPE my_type IS
TABLE OF VARCHAR2(256) INDEX BY BINARY_INTEGER;
FUNCTION my_func return my_type;
END my_package;
And body with function my_func from which I return collection of restaurants:
CREATE OR REPLACE PACKAGE BODY my_package is
FUNCTION my_func RETURN my_type IS
restaurants_table my_type;
BEGIN
select ADRESS
BULK COLLECT INTO restaurants_table
from restaurants
FETCH NEXT 3 ROWS ONLY;
RETURN restaurants_table;
END my_func;
END my_package;
I want to call this function:
declare
TYPE my_type IS
TABLE OF VARCHAR2(256) INDEX BY BINARY_INTEGER;
restaurants_table my_type;
begin
restaurants_table := my_package.my_func();
end;
But I get error:
PLS-00382: expression is of wrong type
This happens when I try to assign return value from function to variable:
restaurants_table := my_package.my_func();
How can I call function correctly so I can have return value in my table type variable restaurants_table?
Later I want to print it by index:
dbms_output.put_line(restaurants_table(1));