declare
v_str varchar2(32767);
v_num number;
begin
v_str := '''124''';
v_str := v_str || ',';
v_str := v_str || '''B737-700''';
select count(*) into v_num from item where itemnum in (v_str);
dbms_output.put_line(v_str|| ' ' ||v_num);
end;输出结果:'124','B737-700' 0
说明v_str为'124','B737-700',而itemnum in (v_str)应该为itemnum in ('124','B737-700')
但是输出结果为空;
select count(*) into v_num from item where itemnum in ('124','B737-700');这个结果为2
v_str varchar2(32767);
v_num number;
begin
v_str := '''124''';
v_str := v_str || ',';
v_str := v_str || '''B737-700''';
select count(*) into v_num from item where itemnum in (v_str);
dbms_output.put_line(v_str|| ' ' ||v_num);
end;输出结果:'124','B737-700' 0
说明v_str为'124','B737-700',而itemnum in (v_str)应该为itemnum in ('124','B737-700')
但是输出结果为空;
select count(*) into v_num from item where itemnum in ('124','B737-700');这个结果为2
这条语句你为什么就可以直接连接起来
-------------------------------------------------------------------------
因为 v_str 是一个字符串' '124','B737-700' ',而不是一组字符串 '124','B737-700'。
in('''124'',''B737-700''')
你说可能可以吗?
where instr(v_str,''''|| itemnum ||'''') >0;
--or:vstr :='124,B737-700'
vstr :=','|| vstr || ',' select * from t
where instr(v_str,','|| itemnum ||',') >0;