So I'm currently transcribing OracleSQL into a new PostgreSQL database. While I'm translating Oracle's (+)
joins to LEFT OUTER JOIN
s, this works very well.
Except when combined with old style joins. Take this OracleSQL for example:
SELECT
*
FROM
table1,
table2 alias1,
table2 alias2,
table2 alias3,
table3,
table4,
table5,
table6 table6alias
WHERE
table1.id_table3 = alias1.id_table3
AND table1.id_table4 = alias2.id_table4
AND table1.id_table3 = table3.id_table3
AND table1.id_table4 = table4.id_table4
AND table1.id_table5 = table5.id_table5
AND table1.table1_id_table3_sender = alias3.id_table3 (+)
AND alias1.id_svw_uebertragungsweg = table6alias.id_svw
AND table1.id_table3 != 0
AND ( table1.id_usr = 0
OR table1.id_usr IS NULL )
It works very well on Oracle's SQL Developer. So I tried transcribing it like this:
SELECT
*
FROM
table1,
table2 alias1,
table2 alias2,
table3,
table4,
table5,
table6 table6alias
LEFT OUTER JOIN table2 alias3
ON table1.table1_id_table3_sender = alias3.id_table3
WHERE
table1.id_table3 = alias1.id_table3
AND table1.id_table4 = alias2.id_table4
AND table1.id_table3 = table3.id_table3
AND table1.id_table4 = table4.id_table4
AND table1.id_table5 = table5.id_table5
AND alias1.id_svw_uebertragungsweg = table6alias.id_svw
AND table1.id_table3 != 0
AND ( table1.id_usr = 0
OR table1.id_usr IS NULL )
Giving me this error:
ORA-00904: "table1"."table1_id_table3_sender": invalid identifier 00904. 00000 - "%s: invalid identifier" *Cause:
*Action: Error on line: 12 row: 8
I've already done only the JOIN, and then it works flawlessly. When adding just one single other JOIN, it gives me this error, that the row can't be found (invalid identifier).
I've already read on the internet that LEFT JOINs don't red more than the first table of the FROM statement. But in this case that would be enough (in my view) - also just adding one other table leads to the error.
So what is my approach to solve this translation to PostgreSQL? Do I have to rewrite ALL of the old style JOINs into newer style ones (which would be very tedious, as there are a ton of these SELECTs) or is there something I just don't get my eyes on?