问题描述
你好,问一下汤姆团队。
我有几个删除语句,我希望它们都在一个存储过程中以简化执行。所有这些语句都将在where条件中使用不同的字符串值。
删除
来自用户1.table4 t4
其中t4.id在 (选择t3.id
来自用户1.table3 t3
其中t3.id在 (选择t2.id
从user1.table2 t2,
用户1.表1 t1
其中t1.id = t2.id
和t1.sender _doc IN ('1234567','8901234','5678912');
删除
来自用户1.table5 t5
其中t5.id在 (选择t3.id
来自用户1.table3 t3
其中t3.id在 (选择t2.id
从user1.table2 t2,
用户1.表1 t1
其中t1.id = t2.id
和t1.sender _doc IN ('1234567','8901234','5678912');
Requirement:
Create a stored procedure where you can pass one or n string parameters. E.g.
EXEC user.SP1 (“1234567”,“8901234”,“5678912”,“nn');
提前感谢。
我有几个删除语句,我希望它们都在一个存储过程中以简化执行。所有这些语句都将在where条件中使用不同的字符串值。
删除
来自用户1.table4 t4
其中t4.id在 (选择t3.id
来自用户1.table3 t3
其中t3.id在 (选择t2.id
从user1.table2 t2,
用户1.表1 t1
其中t1.id = t2.id
和t1.sender _doc IN ('1234567','8901234','5678912');
删除
来自用户1.table5 t5
其中t5.id在 (选择t3.id
来自用户1.table3 t3
其中t3.id在 (选择t2.id
从user1.table2 t2,
用户1.表1 t1
其中t1.id = t2.id
和t1.sender _doc IN ('1234567','8901234','5678912');
Requirement:
Create a stored procedure where you can pass one or n string parameters. E.g.
EXEC user.SP1 (“1234567”,“8901234”,“5678912”,“nn');
提前感谢。
专家解答
你不能将一个IN列表作为字符串传递!
围绕这个传递值作为数组的一种方法:
围绕这个传递值作为数组的一种方法:
create table t as
select level c1 from dual
connect by level <= 100;
create or replace type n_arr
is table of number;
/
create or replace procedure p ( vals n_arr ) as
begin
delete t
where c1 in (
select column_value from table ( vals )
);
end p;
/
select count(*) from t;
COUNT(*)
100
declare
vals n_arr;
begin
vals := n_arr ( 1, 3, 9, 27, 81 );
p ( vals );
end;
/
select count(*) from t;
COUNT(*)
95 文章转载自ASKTOM,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




