我有一个 plsql 过程,它需要一个数据数组并更新一堆记录,我可以用一个 for 循环来做到这一点。我真的可以在没有循环的情况下使用一些帮助来解决这个问题。
包装规格和主体:
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;
/
我想拥有的:
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;
当我尝试上述方法时出现错误,请帮助。非常感谢你。