当前位置: 代码迷 >> Oracle管理 >> sql查询时如何才能将一个集合作为条件
  详细解决方案

sql查询时如何才能将一个集合作为条件

热度:120   发布时间:2016-04-24 04:17:02.0
sql查询时怎么才能将一个集合作为条件
RT
例如:

list = “1”,“2”,“3”,“5“,“11”,“15”,“18”,“13”,“19”,“21”,“14”,“16”,“10”...........;
如何将它作为
select  *   from  table   where    num    not   in   (list); 
的参数!求大神解救!
------解决方案--------------------
引用:
Quote: 引用:

Quote: 引用:

RT
例如:

list = “1”,“2”,“3”,“5“,“11”,“15”,“18”,“13”,“19”,“21”,“14”,“16”,“10”...........;
如何将它作为
select  *   from  table   where    num    not   in   (list); 
的参数!求大神解救!

动态SQL


能给举个例子吗?


-- Created on 7/23/2014 by LEONCHENG 
declare
  -- Local variables here
  l_str    varchar2(100);
  l_sql    varchar2(200);
  l_fnd_id varchar2(8);
begin
  l_str := '''MPGF''';
  l_sql := 'select fnd_id from (select ''MPGF'' FND_ID FROM DUAL UNION SELECT ''MPCF'' FROM DUAL) where fnd_id in(' 
------解决方案--------------------

           l_str 
------解决方案--------------------
 ')';
  DBMS_OUTPUT.put_line(l_sql);
  execute immediate l_sql
    into l_fnd_id;
  DBMS_OUTPUT.put_line(l_fnd_id);
end;
  相关解决方案