本人想在触发器中实现一个变量判断语句,如下:
v_item_cut := ''''||50204||''''||chr(44)||''''||50404||'''';
if a in(v_item_cut) then...
这样写不成功,发现是in里的逗号识别不了,用转义字符也不行。
请指教。
------解决方案--------------------
- SQL code
SQL> declare
2 s nvarchar2(5);
3 v_item_cut nvarchar2(100);
4 begin
5 s:='50204';
6 v_item_cut := ''''||'50204'||''''||','||''''||'50404'||'''';
7 dbms_output.put_line(v_item_cut);
8 if INSTR(v_item_cut,S)>0 then
9 dbms_output.put_line('in');
10 else
11 dbms_output.put_line('Not in');
12 end if;
13 end;
14 /
'50204','50404'
in
PL/SQL procedure successfully completed
SQL
------解决方案--------------------
if item_code in('50204','50404') then..
'50204','50404'是一串列表值
v_item_cut 是变量,它的值是字符串;
这有根本上的区别,in(变量)中的变量值不可能变成列表
可以用 if instr(v_item_cut,item_code)>0 then