代码如下:     
       select cb.id,
               cb.code,
               cb.centercode,
               cb.iperiod,
               cb.deprt,
               cb_l.booksid
        from   cfa_books cb,
               cfa_books cb_l
        where  
        and    cb_l.code(+) = cb.code
        and    cb_l.centercode(+) = cb.centercode
        and    cb_l.iperiod(+) = to_char((to_date(cb.iperiod, 'yyyymm') - 1), 'yyyymm')
        and    cb_l.id(+) = 1
        and    cb_l.flag(+) = 1小弟不明白的是:
        and    cb_l.iperiod(+) = to_char((to_date(cb.iperiod, 'yyyymm') - 1), 'yyyymm')
        and    cb_l.id(+) = 1
        and    cb_l.flag(+) = 1
明明是链接,怎么可以用表的列和常量链接那?这到底代表什么意思?可行的吗?如果在Oracle可行,那么转换成Microsoft SQL Server的存储过程该怎么转换?
谢谢指点!

解决方案 »

  1.   

    如果对常量不用外连接会导致外连接失效,与等值连接效果相同。在对表cfa_books做外连接时所有的字段后面都要有(+)
      

  2.   

    楼上的意思是不是说:Oracle只要进行外联接,都必须使用(+)。
    如果转换为Microsoft SQL Server的存储过程是不是等于:
            select cb.id,
                   cb.code,
                   cb.centercode,
                   cb.iperiod,
                   cb.deprt,
                   cb_l.booksid
            from   cfa_books cb,
                   cfa_books cb_l
            where  
            and    cb_l.code *= cb.code
            and    cb_l.centercode *= cb.centercode
            and    cb_l.iperiod = to_char((to_date(cb.iperiod, 'yyyymm') - 1), 'yyyymm')
            and    cb_l.id = 1
            and    cb_l.flag = 1
      

  3.   

    如果要转换为标准的SQL,应该是这样:       select cb.id,
                   cb.code,
                   cb.centercode,
                   cb.iperiod,
                   cb.deprt,
                   cb_l.booksid
            from   cfa_books cb
            right outer join cfa_books cb_l
            on(cb_l.code = cb.code and cb_l.centercode = cb.centercode)
            where  cb_l.iperiod = to_char((to_date(cb.iperiod, 'yyyymm') - 1), 'yyyymm')
            and    cb_l.id = 1
            and    cb_l.flag = 1