正确:
 select a.pk_billtype,
        c.user_name,
        substr(a.senddate, 1, 10) as SENDDATE,
        a.billno,
        a.checkman,
        d.billtypename billname
   from pub_workflownote a
   left join ty_bz b on a.billid = b.pk_tybz
   left join ty_bzjy_bg_h ss on a.billid = ss.pk_tyjy_bg
   left join sm_user c on (b.voperatorid = c.cuserid or
                          ss.voperatorid = c.cuserid)
   left join bd_billtype d on (b.pk_billtype = d.pk_billtypecode or
                              ss.pk_billtype = d.pk_billtypecode)
  where (a.ischeck = 'N' and
        (a.approvestatus in (0, 2) or a.approvestatus is null) and
        a.dr = 0 and a.actiontype <> 'BIZ' and a.actiontype <> 'MAKEBILL')
    and a.pk_billtype in ('CL', 'R3', 'JK', 'FJY', 'PO', 'J1', 'BJ')
    and a.checkman = '0001V31000000003O5G9'
  order by a.senddate desc错误: select a.pk_billtype,
        c.user_name,
        substr(a.senddate, 1, 10) SENDDATE,
        a.billno,
        a.checkman,
        d.billtypename billname
   from pub_workflownote a,
        ty_bz            b,
        ty_bzjy_bg_h     ss,
        sm_user          c,
        bd_billtype      d
  where a.billid = b.pk_tybz(+)
    and a.billid = ss.pk_tyjy_bg(+)
    
    and (b.voperatorid = c.cuserid(+) or ss.voperatorid = c.cuserid(+))//ORA-01719
    and (b.pk_billtype = d.pk_billtypecode(+) or
        ss.pk_billtype = d.pk_billtypecode(+))//ORA-01719
    and ((a.ischeck = 'N' and
        (a.approvestatus in (0, 2) or a.approvestatus is null) and
        a.dr = 0 and a.actiontype <> 'BIZ' and a.actiontype <> 'MAKEBILL') and
        a.pk_billtype in ('CL', 'R3', 'JK', 'FJY', 'PO', 'J1', 'BJ') and
        a.checkman = '0001V31000000003O5G9')
  order by a.senddate desc请各位大虾请教,修改。谢谢

解决方案 »

  1.   

    ORA-01719: outer join operator (+) not allowed in operand of OR or IN 
    Cause: An outer join appears in an or clause.
    Action: If A and B are predicates, to get the effect of (A(+) or B), try (select where (A(+) and not B)) union all (select where (B)).
      

  2.   

    按提示是要你把句子拆成两个,有有两处or,也就是要拆成4个union all的句子...
      

  3.   

    大概是这样.
    select * from (
    select a.pk_billtype,
      c.user_name,
      substr(a.senddate, 1, 10) SENDDATE,
      a.billno,
      a.checkman,
      d.billtypename billname
      from pub_workflownote a,
      ty_bz b,
      ty_bzjy_bg_h ss,
      sm_user c,
      bd_billtype d
      where a.billid = b.pk_tybz(+)
      and a.billid = ss.pk_tyjy_bg(+)
        
      and b.voperatorid = c.cuserid(+) and ss.voperatorid != c.cuserid(+)
      and b.pk_billtype = d.pk_billtypecode(+) and ss.pk_billtype != d.pk_billtypecode(+)
      and ((a.ischeck = 'N' and
      (a.approvestatus in (0, 2) or a.approvestatus is null) and
      a.dr = 0 and a.actiontype <> 'BIZ' and a.actiontype <> 'MAKEBILL') and
      a.pk_billtype in ('CL', 'R3', 'JK', 'FJY', 'PO', 'J1', 'BJ') and
      a.checkman = '0001V31000000003O5G9')
    union all 
    select a.pk_billtype,
      c.user_name,
      substr(a.senddate, 1, 10) SENDDATE,
      a.billno,
      a.checkman,
      d.billtypename billname
      from pub_workflownote a,
      ty_bz b,
      ty_bzjy_bg_h ss,
      sm_user c,
      bd_billtype d
      where a.billid = b.pk_tybz(+)
      and a.billid = ss.pk_tyjy_bg(+)
        
     and ss.voperatorid = c.cuserid(+)
      and b.pk_billtype = d.pk_billtypecode(+) and ss.pk_billtype != d.pk_billtypecode(+))
      and ((a.ischeck = 'N' and
      (a.approvestatus in (0, 2) or a.approvestatus is null) and
      a.dr = 0 and a.actiontype <> 'BIZ' and a.actiontype <> 'MAKEBILL') and
      a.pk_billtype in ('CL', 'R3', 'JK', 'FJY', 'PO', 'J1', 'BJ') and
      a.checkman = '0001V31000000003O5G9')
    union all
    select a.pk_billtype,
      c.user_name,
      substr(a.senddate, 1, 10) SENDDATE,
      a.billno,
      a.checkman,
      d.billtypename billname
      from pub_workflownote a,
      ty_bz b,
      ty_bzjy_bg_h ss,
      sm_user c,
      bd_billtype d
      where a.billid = b.pk_tybz(+)
      and a.billid = ss.pk_tyjy_bg(+)
        
      and b.voperatorid = c.cuserid(+) and ss.voperatorid != c.cuserid(+)
      and ss.pk_billtype = d.pk_billtypecode(+)
      and ((a.ischeck = 'N' and
      (a.approvestatus in (0, 2) or a.approvestatus is null) and
      a.dr = 0 and a.actiontype <> 'BIZ' and a.actiontype <> 'MAKEBILL') and
      a.pk_billtype in ('CL', 'R3', 'JK', 'FJY', 'PO', 'J1', 'BJ') and
      a.checkman = '0001V31000000003O5G9')
    union all 
    select a.pk_billtype,
      c.user_name,
      substr(a.senddate, 1, 10) SENDDATE,
      a.billno,
      a.checkman,
      d.billtypename billname
      from pub_workflownote a,
      ty_bz b,
      ty_bzjy_bg_h ss,
      sm_user c,
      bd_billtype d
      where a.billid = b.pk_tybz(+)
      and a.billid = ss.pk_tyjy_bg(+)
        
     and ss.voperatorid = c.cuserid(+)
      and ss.pk_billtype = d.pk_billtypecode(+)
      and ((a.ischeck = 'N' and
      (a.approvestatus in (0, 2) or a.approvestatus is null) and
      a.dr = 0 and a.actiontype <> 'BIZ' and a.actiontype <> 'MAKEBILL') and
      a.pk_billtype in ('CL', 'R3', 'JK', 'FJY', 'PO', 'J1', 'BJ') and
      a.checkman = '0001V31000000003O5G9')
      )  order by senddate desc
      

  4.   

    用left join吧,(+)的形式已经比较老了.用起来也容易出错.
      

  5.   

    ??
    没有吧.
    记得以前只支持(+)的形式,现在支持left join了
      

  6.   

    在or 或者in中不支持老的外连接写法,也就是a.id=b.id(+) 这样的左连接写法
    必须是a left join b on a.id=b.id or
      

  7.   

    得用union all来 select a.pk_billtype,
      c.user_name,
      substr(a.senddate, 1, 10) SENDDATE,
      a.billno,
      a.checkman,
      d.billtypename billname
      from pub_workflownote a,
      ty_bz b,
      ty_bzjy_bg_h ss,
      sm_user c,
      bd_billtype d
      where a.billid = b.pk_tybz(+)
      and a.billid = ss.pk_tyjy_bg(+)
        
      and b.voperatorid = c.cuserid(+) 
      and b.pk_billtype = d.pk_billtypecode(+) 
      and ((a.ischeck = 'N' and
      (a.approvestatus in (0, 2) or a.approvestatus is null) and
      a.dr = 0 and a.actiontype <> 'BIZ' and a.actiontype <> 'MAKEBILL') and
      a.pk_billtype in ('CL', 'R3', 'JK', 'FJY', 'PO', 'J1', 'BJ') and
      a.checkman = '0001V31000000003O5G9')union  all
    select a.pk_billtype,
      c.user_name,
      substr(a.senddate, 1, 10) SENDDATE,
      a.billno,
      a.checkman,
      d.billtypename billname
      from pub_workflownote a,
      ty_bz b,
      ty_bzjy_bg_h ss,
      sm_user c,
      bd_billtype d
      where a.billid = b.pk_tybz(+)
      and a.billid = ss.pk_tyjy_bg(+)
        
      and b.voperatorid = c.cuserid(+) 
      and ss.pk_billtype = d.pk_billtypecode(+)
      and ((a.ischeck = 'N' and
      (a.approvestatus in (0, 2) or a.approvestatus is null) and
      a.dr = 0 and a.actiontype <> 'BIZ' and a.actiontype <> 'MAKEBILL') and
      a.pk_billtype in ('CL', 'R3', 'JK', 'FJY', 'PO', 'J1', 'BJ') and
      a.checkman = '0001V31000000003O5G9')
    union all
    select a.pk_billtype,
      c.user_name,
      substr(a.senddate, 1, 10) SENDDATE,
      a.billno,
      a.checkman,
      d.billtypename billname
      from pub_workflownote a,
      ty_bz b,
      ty_bzjy_bg_h ss,
      sm_user c,
      bd_billtype d
      where a.billid = b.pk_tybz(+)
      and a.billid = ss.pk_tyjy_bg(+)
        
      and ss.voperatorid = c.cuserid(+)
      and b.pk_billtype = d.pk_billtypecode(+) 
      and ((a.ischeck = 'N' and
      (a.approvestatus in (0, 2) or a.approvestatus is null) and
      a.dr = 0 and a.actiontype <> 'BIZ' and a.actiontype <> 'MAKEBILL') and
      a.pk_billtype in ('CL', 'R3', 'JK', 'FJY', 'PO', 'J1', 'BJ') and
      a.checkman = '0001V31000000003O5G9')
    union all
    select a.pk_billtype,
      c.user_name,
      substr(a.senddate, 1, 10) SENDDATE,
      a.billno,
      a.checkman,
      d.billtypename billname
      from pub_workflownote a,
      ty_bz b,
      ty_bzjy_bg_h ss,
      sm_user c,
      bd_billtype d
      where a.billid = b.pk_tybz(+)
      and a.billid = ss.pk_tyjy_bg(+)
        
      and ss.voperatorid = c.cuserid(+)
      and ss.pk_billtype = d.pk_billtypecode(+)
      and ((a.ischeck = 'N' and
      (a.approvestatus in (0, 2) or a.approvestatus is null) and
      a.dr = 0 and a.actiontype <> 'BIZ' and a.actiontype <> 'MAKEBILL') and
      a.pk_billtype in ('CL', 'R3', 'JK', 'FJY', 'PO', 'J1', 'BJ') and
      a.checkman = '0001V31000000003O5G9') 
      

  8.   

    各位大虾,这样不会SQL性能很差啊
      

  9.   

    其实,我也不想着么做也没有办法。在程序的角度上使用标准的SQL语法而到了底层运行SQL的时候,我们的标准SQL都会被强制转换成ORALCE10G优化版的SQL语句,这让我非常头痛我跟踪BUG发现了着样的问题,如果我修改的话那么可能会影响很多人的代码业务逻辑这样风险非常大,所以没有办法,只能着样做啦.最后,根据诸位的解题思路.明白,在碰见同等问题该如何解决了.正确SQL展示:
    select a.pk_billtype,
      c.user_name,
      substr(a.senddate, 1, 10) SENDDATE,
      a.billno,
      a.checkman,
      d.billtypename billname
      from pub_workflownote a,
      ty_bz b,
      sm_user c,
      bd_billtype d
      where a.billid = b.pk_tybz(+)    
      and b.voperatorid = c.cuserid(+)  
      and b.pk_billtype = d.pk_billtypecode(+)  
      and ((a.ischeck = 'N' and
      (a.approvestatus in (0, 2) or a.approvestatus is null) and
      a.dr = 0 and a.actiontype <> 'BIZ' and a.actiontype <> 'MAKEBILL') and
      a.pk_billtype in ('CL', 'R3', 'JK', 'FJY', 'PO', 'J1') and
      a.checkman = '0001V31000000003O5G9')union all
    select a.pk_billtype,
      c.user_name,
      substr(a.senddate, 1, 10) SENDDATE,
      a.billno,
      a.checkman,
      d.billtypename billname
      from pub_workflownote a,
      ty_bzjy_bg_h ss,
      sm_user c,
      bd_billtype d
      where a.billid = ss.pk_tyjy_bg(+)
      and ss.voperatorid = c.cuserid(+)  
      and ss.pk_billtype = d.pk_billtypecode(+)
      and ((a.ischeck = 'N' and
      (a.approvestatus in (0, 2) or a.approvestatus is null) and
      a.dr = 0 and a.actiontype <> 'BIZ' and a.actiontype <> 'MAKEBILL') and
      a.pk_billtype in ('BJ') and
      a.checkman = '0001V31000000003O5G9')
    order by senddate desc