在procedure中,如何输出某个SQL语句块的内容,如下面红色字体部门。
主要是想检查变量是否正确传值?
create or replace procedure test_procedure is   v_lottype       varchar2(40);begin
   v_lottype:='(''P'',''R'',''M'',''E1'',''E2'',''E3'',''E9'')';
   --v_lottype:='(' ||'P'||','||'R'||','||'M'||','||'E1'||','||'E2'||','||'E3'||','||'E9'||')';
   v_cuthour:='00';--dbms_output.put_line('v_rwprod : ' || v_rwprod);    --v_eoh
   select nvl(sum(componentqty),0) into v_eoh from mfg_tbl_info_wip_hourly_ii
   where lottype in v_lottype
   and productname not like 'RW%'
   and stage not in (select distinct stage from probe_stage where type = 'ALL')
   and adstatus != 'Bank'
   and histdate=to_char(sysdate,'yyyymmdd')
   and hour= v_cuthour ;
  
  --dbms_output.put_line('SQLERRM : ' || SQLERRM);
  
end;Best Regards
Linda Liu

解决方案 »

  1.   

    动态SQL...
    v_sql := '
    select nvl(sum(componentqty),0) from mfg_tbl_info_wip_hourly_ii
    where lottype in v_lottype
    and productname not like ''RW%''
    and stage not in (select distinct stage from probe_stage where type = ''ALL'')
    and adstatus != ''Bank''
    and histdate=to_char(sysdate,''yyyymmdd'')
    and hour= v_cuthour';
    dbms_output.put_line(v_sql);--执行
    execute immediate v_sql into v_eoh;...
      

  2.   

    遇到错误"ORA-20000: ORU-10028: line length overflow, limit of 255 chars per line"用了set serveroutput on size 100000还是不得行
      

  3.   

    一定要通过截取的方式吗?“set serveroutput on size 100000” 这个就不行吗?
    用的是ORACLE 9i
      

  4.   

    on size 的长度也是有限制的.
    貌似也是用的varchar,超过4000就不成了,你可以测试下.