create or replace procedure P_CabLocGrid (v_start in  number,v_sum  in number,condition in varchar2,v_result out sys_refcursor)
is
begin
  
 if  condition is not null and condition<>'' then 
       execute immediate   'open v_result for select distinct substr(PLACE_SN,v_start,v_sum) from T_BLANK_CERT_VISA where AREA_CODE=' || condition  ;
 end if ;
  
end P_CabLocGrid;
***************************************************************************execute immediate   'open v_result for select distinct substr(PLACE_SN,v_start,v_sum) from T_BLANK_CERT_VISA where AREA_CODE=' || condition ;
而且上面这句话要加一个varchar2的字符串,如果加入这个条件呢,

解决方案 »

  1.   

    create or replace procedure P_CabLocGrid (v_start in  number,v_sum  in number,condition in varchar2,v_result out sys_refcursor)
    is
    begin
      
     if  condition is not null and condition<>'' then 
    open v_result for 'select distinct substr(PLACE_SN,v_start,v_sum) from T_BLANK_CERT_VISA where AREA_CODE=:v1 and xxxx=:v2 and ...' using condition,condition ...  ;
     end if ;
      
    end P_CabLocGrid;