今天写存储过程的时候,遇到了传入多个参数,不能用in匹配的问题。
例如:
传入参数:
b = 'a','b','c';
pl/sql语句:
select * from table
where var in ( + b + );
不能匹配,因为pl/sql把b当做一个完整的字符串, select * from table where var in (''a','b','c'');
解决方法:
传入参数:
b = a,b,c;
pl/sql语句:
str:= ','||b||',';
select * from table
where instr(str,','||var||',') > 0
解释: 把传入的参数拼接为: str = ,a,b,c,;
instr 判断 str中是否有 ,var, 存在。