---采购订单体
select a.corder_bid,a.corderid from po_order_b a where a.iisactive = 0 ---是否激活
and a.corderid in(--采购订单头id
select b.corderid from po_order b where b.breturn='N'--是否退货
--and forderstatus ---订单状态 0或3
and b.corderid in (select c.cfirstbillhid from ic_general_b c where c.bonroadflag<>'N')---bonroadflag是否在途,
)上面的是我的sql语句,就是有错误,错误信息如下
命令出错, 行: 3 列: 17
错误报告:
SQL 错误: ORA-00911: invalid character
00911. 00000 -  "invalid character"
*Cause:    identifiers may not start with any ASCII character other than
           letters and numbers.  $#_ are also allowed after the first
           character.  Identifiers enclosed by doublequotes may contain
           any character other than a doublequote.  Alternative quotes
           (q'#...#') cannot use spaces, tabs, or carriage returns as
           delimiters.  For all other contexts, consult the SQL Language
           Reference Manual.
*Action:
就是不要改变原意,我初学,不知道怎么改正,请指点一下那里错了,应该怎样改,共同学习

解决方案 »

  1.   

    ---采购订单体
    select a.corder_bid,a.corderid from po_order_b a where a.iisactive = 0 ---是否激活
    and a.corderid in(--采购订单头id
    select b.corderid from po_order b where b.breturn='N')--是否退货
    --and (forderstatus='0' or forderstatus='3') ---订单状态 0或3
    and b.corderid in (select c.cfirstbillhid from ic_general_b c where c.bonroadflag<>'N')---bonroadflag是否在途,
      

  2.   

    #1楼 你的回答就不对,怎么把b.corderid  给我括外边了,不是要改变我的原意嘛?
    测试过了不行
    #2楼 那里的分号? 最后的那行的注释,是页面div中的行数字符有限才迫使换行的
      

  3.   

    --你搞这么多的嵌套速度会有影响的
    select a.corder_bid,a.corderid from po_order_b a,po_order b,ic_general_b  c
    where a.corderid=b.corderid and b.corderid=c.cfirstbillhid 
    and a.iisactive = 0 and b.breturn='N' and c.bonroadflag<>'N'
      

  4.   

    --and forderstatus ---订单状态 0或3  到底是全部注释还是什么
      

  5.   

    select a.corder_bid, a.corderid
      from po_order_b a
     where a.iisactive = 0 ---是否激活
       and a.corderid in(( --采购订单头id
      select b.corderid
              from po_order b
             where b.breturn = 'N' --是否退货
                  --and forderstatus ---订单状态 0或3
               and b.corderid in ( select c.cfirstbillhid
                                    from ic_general_b c
                                   where c.bonroadflag <> 'N') ---bonroadflag
    括弧不对
      

  6.   

    你放到plsql里面看看2个括弧一个大一个小
      

  7.   

    抛去订单状态不讲,5的SQL是正解。最多是在where里加上订单状态的过滤。