我明白你的意思了  但我是写在存储过程里 不能不加引号 代码如下procedure getPwkPjtjxxList_Bydate_XZQ(CUR_OUT OUT cur_OUT)
is
v_Wdta number(5):=0;
v_Hb_Wdta number(4):=5;
begin
     open CUR_OUT for
      'select case when '||v_Wdta||' !=0 then '||(v_Hb_Wdta/v_Wdta)||' else 0 end as    wdta  from wq_sdwas_d where stcd=''309A5821''';end;在这里就不知道该如何处理了! 着急啊

解决方案 »

  1.   

    v_Wdta明明是0, 但select case却判断不为0.
    那是因为v_Wdta 不是整数型, 所以v_Wdta 永远不会等于 整型的0.解决方法:
    1. 利用exception handler处理, 发生除数为0的exception,就写另一个sql.
    2. when '||v_Wdta||' !=0 改为 when '||v_Wdta||' !=0.00  ,  这个方法不一定成功,试试~
      

  2.   

    身边没环境,给个可以执行的MS sql代码看看
     Exec('select case when '+ '5' +' !=0 then (' + '3'+' /' + '5' + ') else 0 end as wdta from herd ')