2014-10-10 54 views
-2

請幫忙檢查下面的SQL語句在Oracle 11g R2上執行時出現「ORA-00936:缺少表達式」錯誤的原因。以下SQL語句錯誤「ORA-00936:缺少表達式」

select part.*, 
     decode(pv.dspuom, null, part.untqty, part.untqty/prtftp_dtl.untqty) dsp_untqty, 
     decode(pv.dspuom, null, pv.stkuom, pv.dspuom) untqty_uom, 
     decode(pv.dspuom, null, cast(null as int), pv.stkuom, cast(null as int), mod(part.untqty, prtftp_dtl.untqty)) rem_untqty, 
     decode(pv.dspuom, null, null, pv.stkuom, null, pv.stkuom) rem_untqty_uom 
    from (select @select_on:raw sum(untqty) untqty, 
       sum(catch_qty) catch_qty, 
       invadj.prtnum fixed_prtnum, 
       invadj.prt_client_id fixed_prt_client_id, 
       invadj.wh_id fixed_wh_id, 
       invadj.play_prc_id 
      from invadj 
      where exists(select 'x' 
         from prtmst_view 
         where prtmst_view.prtnum = invadj.prtnum 
          and prtmst_view.prt_client_id = invadj.prt_client_id 
          and prtmst_view.wh_id = invadj.wh_id 
          and prtmst_view.prdflg = 1) 
      and @+moddte:date 
      and @+invadj.play_prc_id 
      and @+invadj.prtnum 
      and @+invadj.prt_client_id 
      and wh_id = @wh_id 
      and @* 
      group by @result_string:raw, 
       invadj.prtnum, 
       invadj.prt_client_id, 
       invadj.wh_id, 
       invadj.play_prc_id 
     having sum(untqty) <> 0 
      or sum(catch_qty) <> 0) part left 
    join prtmst_view pv 
    on pv.prtnum = part.fixed_prtnum 
    and pv.prt_client_id = part.fixed_prt_client_id 
    and pv.wh_id = part.fixed_wh_id left 
    join prtftp 
    on prtftp.prtnum = pv.prtnum 
    and prtftp.prt_client_id = pv.prt_client_id 
    and prtftp.wh_id = pv.wh_id 
    and prtftp.defftp_flg = 1 left 
    join prtftp_dtl 
    on prtftp.prtnum = prtftp_dtl.prtnum 
    and prtftp.ftpcod = prtftp_dtl.ftpcod 
    and prtftp.prt_client_id = prtftp_dtl.prt_client_id 
    and prtftp.wh_id = prtftp_dtl.wh_id 
    and prtftp_dtl.uomcod = nvl(pv.dspuom, pv.stkuom)  
+4

_ @ _是Oracle無效! – 2014-10-10 15:52:47

+0

@ *有點可疑... – 2014-10-10 15:52:54

+0

有人可以驗證http://sqlfiddle.com/#!4上的修復解決方案嗎? – 2014-10-10 16:08:47

回答

0

我覺得語法可能會有點偏離。

看這條線之下

FROM (SELECT @ select_on:raw sum(untqty) untqty, 

@字符似乎很奇怪