当前位置: 代码迷 >> Oracle开发 >> oralce in 查询不能传入字符串,该怎么处理
  详细解决方案

oralce in 查询不能传入字符串,该怎么处理

热度:333   发布时间:2016-04-24 07:43:28.0
oralce in 查询不能传入字符串
declare
 var_catids varchar2(256) default '';
 int_pp integer default 0;

begin 

 var_catids :='1640,1633,1635';
select max(pp) into int_pp from table1 where id in (var_catids);
dbms_output.put_line('int_pp:'||int_pp);
end;

把select max(pp) into int_pp from table1 where id in (var_catids);这语句换成如下就正常了
select max(pp) into int_pp from table1 where id in (1640,1633,1635);

哪位高手帮我看看.

------解决方案--------------------
SQL code
declare var_catids varchar2(256) default ''; int_pp integer default 0; tem_sql varchar(2000);begin var_catids :='1640,1633,1635'; temp_sql:='select max(pp)  from  table1 where  id in ('||var_catids||')'; execute immediate temp_sql into int_pp ;dbms_output.put_line('int_pp:' ¦ ¦int_pp); end;
------解决方案--------------------
正解
探讨
SQL codedeclare
var_catids varchar2(256) default '';
int_pp integer default 0;
tem_sql varchar(2000);
begin

var_catids :='1640,1633,1635';
temp_sql:='select max(pp) from table1 where id in ('||var_catids||')';
execute immediate temp_sql into int_pp ;
dbms_output.put_line('int_pp:' ¦ ¦int_pp);
end;


你这样去试试看
  相关解决方案