oracle中

msdnchina發表於2009-04-10

浪潮軟體有個功能(pb開發的client端軟體),點選時報錯:
ORA-01719: OR 或 IN 運算元中不允許外部聯接運算子 (+)

SELECT 'L',     KCXED1_LSBH, KCXED1_DJRQ, KCXED1_SJDH, KCXED1_BMBH, KCXED1_JHBH, KCXED1_CPBH, KCXED1_CPBH, LSWLZD_GGXH, KCXED1_CPSL, KCXED1_CPPC, KCXED1_LRXM, KCXED1_BZ,   KCXED1_KCXM, KCXED1_KCSH, KCXED1_KCRQ, KCXED1_KCJZ, KCXED1_WCBZ, KCXED1_CPRQ, KCXED1_C1,  KCXED1_C2,  KCXED1_C3,   KCXED1_C4,   KCXED1_C5,  KCXED1_U1,  KCXED1_U2,  KCXED1_U3,  KCXED1_SFQR, KCXED1_KCXGSJ, KCXED1_YWBS, KCXED1_DWGC,  KCXED1_DWGC,  LSWLZD_C1,  LSWLZD_C2,  LSWLZD_C3,  LSWLZD_C4,   LSWLZD_C5,     LSWLZD_U1,     LSWLZD_U2,     LSWLZD_U3  from KCXED1,LSWLZD  where KCXED1_CPBH = LSWLZD_WLBH(+) AND KCXED1_DJRQ>='20090201' AND KCXED1_DJRQ<='20090216'  AND NVL(KCXED1_SJDH,' ') = '09020023'  or  NVL(KCXED1_SJDH,' ') = '09020030'

此語句的where 條件中,是這麼寫的:
where KCXED1_CPBH = LSWLZD_WLBH(+) AND KCXED1_DJRQ>='20090201' AND KCXED1_DJRQ<='20090216'  AND NVL(KCXED1_SJDH,' ') = '09020023'  or  NVL(KCXED1_SJDH,' ') = '09020030'
也就是用了外連線(OUTER JOIN),只不過 KCXED1_CPBH = LSWLZD_WLBH(+)  是左外連線,這個有點搞笑,左外連線時,"+"放在=的右邊.呵呵....不知道oracle為啥這麼放...

例項:

CREATE TABLE departments

(

 depID  NUMBER(38,0),

 depName VARCHAR2(20),

 delFlag NUMBER(1,0)

);

 
 select * from departments


 select * from employees

CREATE TABLE employees

(

 empID  NUMBER(38,0),

 empName VARCHAR2(20),

 depID  NUMBER(38,0),

 delFlag NUMBER(1,0)

);

 

INSERT INTO departments VALUES(1,'Finacle',0);

INSERT INTO departments VALUES(2,'Marketing',0);

INSERT INTO departments VALUES(3,'HR',1);

INSERT INTO departments VALUES(4,'IT',0);

 

INSERT INTO employees VALUES(1,'wbq',1,0);

INSERT INTO employees VALUES(2,'czh',2,0);

INSERT INTO employees VALUES(3,'chh',1,0);

INSERT INTO employees VALUES(4,'wal',2,0);

INSERT INTO employees VALUES(5,'ddd',3,0);

 

COMMIT;

請執行
select * from employees  e , departments  d where e.depid = d.depid(+)


select * from employees  e , departments  d where e.depid (+) = d.depid

比較一下,這2個sql的異同

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/161195/viewspace-588623/,如需轉載,請註明出處,否則將追究法律責任。

相關文章