2015-08-27 12 views
0

假設我有一個FROM子句,像這樣:在Oracle中,關於語法 - 如何將(+)語法轉換爲現代傳統的JOIN?

FROM 

     apps.po_requisition_lines_all prl, 
     apps.po_requisition_headers_all prha, 
     po.po_req_distributions_all prda, 
     po.po_distributions_all pda, 
     po.po_headers_all pha 
    where 1=1 
     and prl.requisition_header_id= prha.requisition_header_id 
     and prl.requisition_line_id= prda.requisition_line_id 
     and prda.distribution_id= pda.req_distribution_id(+) 
     and pha.po_header_id(+)=pda.po_header_id 

那麼請問這種類型的外部聯接得到轉換,如果我們想正常使用JOIN語法?謝謝 !

+0

可能重複甲骨文(老?)連接 - 一個工具/腳本轉換?] (http://stackoverflow.com/questions/2425960/oracle-old-joins-a-tool-script-for-conversion) – sstan

回答

1

沒有看到的模式,我覺得很難,但是這應該設置你在正確的方向:

FROM apps.po_requisition_lines_all prl 
INNER JOIN apps.po_requisition_headers_all prha ON prl.requisition_header_id = prha.requisition_header_id 
INNER JOIN po.po_req_distributions_all  prda ON prda.requisition_line_id = prl.requisition_line_id 
LEFT JOIN po.po_distributions_all   pda ON prda.distribution_id  = pda.req_distribution_id 
-- I note from the example provided that this is a right join 
-- Without seeing the schema, it looks to me as though it should be left 
-- As I say say, without seeing the schema, I probably shouldn't pass comment 
RIGHT JOIN po.po_headers_all    pha ON pha.po_header_id   = pda.po_header_id; 

對於INNER JOIN你可以說JOIN雖然我認爲明確說INNER艾滋病可讀性。我也注意到提供的例子有WHERE 1=1這是多餘的。

1

+是舊版本的Outer Joins,而且不同點在於+來後等號或之前,但現在它建議使用Join關鍵字,而不是+,關於+跡象,如果說到:

=

select * from t1, t2 
where t1.id=t2.id(+) 

這意味着左外連接

select * from t1 
left outer join t2 on t1.id=t2.id 

之前=

select * from t1, t2 
where t1.id(+)=t2.id 

這意味着右外連接

select * from t1 
Right outer join t2 on t1.id=t2.id 

沒有+

select * from t1, t2 
where t1.id=t2.id 

這意味着內加入

select * from t1 
join t2 on t1.id=t2.id 
相關問題