Skip to content
Advertisement

Correlated Subquery working differently for Oracle 12c and 11g

We have a generic table that holds multiple records (DDL and DML below):

Below are the records:

The query below works in 12c, but Errors out in 11g:

It errors out with ORA-00904: "AR_TRX"."TRX_ID": invalid identifier. I believe this is caused by the correlated subquery AR_TRX linked to the SELECT statement (see comments “– ERROR HERE” above). I need this same query to work for both 12c and 11g. Below are the versions from each Database

11g:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – Production

PL/SQL Release 11.2.0.4.0 – Production “CORE 11.2.0.4.0 Production”

12c:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 – 64bit

Production PL/SQL Release 12.1.0.2.0 – Production

I’ve tried using CTE (Common Table Expressions) such as the WITH clause, but it’s still not working for 11g: I’ve read that there can only be a single-level of the Sub-Query in 11g.

Is there a workaround for 11g?

Please advise. Thank you!

Advertisement

Answer

I was able to resolve this by a solution provided by an SQL Expert Chris Saxon using with WITH CTE. I previously used it as the main driving table, but turns out, it should be at the correlation queries like below:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement