I have a function, which accepts associative array as parameters. Function - before insert/update - needs to check if records exists in table, so I need to loop over array.
Since FORALL doesn't allow SELECT statement, what is the right way to do this ?
Function (just the part I need to fix - It's an example!!):
type t_name is table of MySchema.Orders.NAME%type index by pls_integer;
type t_year is table of MySchema.Orders.YEAR%type index by pls_integer;
type t_month is table of MySchema.Orders.MONTH%type index by pls_integer;
FUNCTION Check_records (name_in IN t_name, year_in IN t_year, month_in IN t_month) RETURN INTEGER
IS
record_exists INTEGER;
BEGIN
FORALL i in name_in.FIRST..name_in.LAST
SELECT COUNT(*) INTO record_exists
FROM MySchema.Orders@link_to_table
WHERE name= name_in(i)
AND year= year_in(i)
AND month= month_in(i);
return record_exist
END Check_records;