I have a plsql procedure which takes an array of data and updates bunch of records, I am able to do this with a for loop. I could really use some help figuring out to do this without a loop.
Package spec and body:
create or replace PACKAGE ARRAY_EXAMPLE AS
type arrtype is table of test_table.name%TYPE index by pls_integer;
PROCEDURE PROCESS_ARRAY( stringArrayIn IN arrtype
, p_city varchar2
, p_phone number);
END;
/
create or replace PACKAGE BODY ARRAY_EXAMPLE AS
PROCEDURE PROCESS_ARRAY( stringArrayIn IN arrtype
, p_city varchar2
, p_phone number) IS
BEGIN
FOR i IN 1..stringArrayIn.Count
LOOP
update test_table t
set t.city = p_city
where t.name = stringArrayIn(i)
and t.phone = p_phone;
END LOOP;
END;
END;
/
What I want to have:
create or replace PACKAGE BODY ARRAY_EXAMPLE AS
PROCEDURE PROCESS_ARRAY( stringArrayIn IN arrtype
, p_city varchar2
, p_phone number) IS
BEGIN
update test_table t
set t.city = p_city
where t.phone = p_phone
and t.name in (stringArrayIn);
END;
END;
I get error when I try the above, please help. thank you very much in advance.