或者传入类型改为 数值 类型然后,定义一个变量 aaaCodeId = substr(aCodeId,1,1)||','||substr(aCodeId,2,1)||','substr(aCodeId,3,1)||','substr(aCodeId,4,1)||','substr(aCodeId,5,1)||' ' if i in (aCodeId) then 改为if i in (aaaCodeId) then
应该把aCordId 的数据解析出来,再做比对?
SQL> ed Wrote file afiedt.buf 1 declare test varchar2(100); 2 begin 3 test:='1,2,3,4,5'; 4 for i in 1..100 loop 5 if instr(','||test||',', ','||i||',')>0 then 6 insert into t(a) 7 values (i); 8 end if; 9 end loop; 10* end ; SQL> /PL/SQL procedure successfully completed.SQL> select * from t; A ---------- 1 2 3 4 5这样改一下应该可以了
改为if i in (aaaCodeId) then
Wrote file afiedt.buf 1 declare test varchar2(100);
2 begin
3 test:='1,2,3,4,5';
4 for i in 1..100 loop
5 if instr(','||test||',', ','||i||',')>0 then
6 insert into t(a)
7 values (i);
8 end if;
9 end loop;
10* end ;
SQL> /PL/SQL procedure successfully completed.SQL> select * from t; A
----------
1
2
3
4
5这样改一下应该可以了
instr(','||test||',', ','||i||',')加','的目的是什么??是不是为了把||i||转换成字符处理?直接用instr(test,i)不可以吗??