比如我有个select语句需要传入参数p_type,假设p_type输入值为('222','3333')
select * from t1 where substr(c1,1,4) in p_type.
那p_type该如何写呢?
谢谢!

解决方案 »

  1.   

    如果不用动态sql,可以吗?因为sql太长了。
      

  2.   


    create or replace procedure procedure_name(
      p_type   varchar2,
      o_cursor sys_refcursor
    )as
    begin
      open o_cursor for 
        'select * from t1 where substr(c1,1,4) in ('||p_type||')';exception
      when others then
        null;
    end;
      

  3.   

    使用动态sql与sql的长短没有任何关系了。
      

  4.   

    没有什么好办法,只有这一条路,动态sql。
      

  5.   

    就是懒,找个写好的动态sql套过去就行了,该3个'的3个,该两个的2个。你就套呗