Skip to Main Content
  • Questions
  • Implementing Old style SQL outer join along with condition query to the new style

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, sunil.

Asked: October 31, 2017 - 10:30 am UTC

Last updated: October 31, 2017 - 10:40 am UTC

Version: 12c

Viewed 1000+ times

You Asked

Hi,
I have SQL outer join query which is written in old format with (+) notation and I am working on its migration to the new presentation and without the (+) notation. I am unable to convert the last line of the query with the outer join condition.

Query in Old style:
SELECT cpd.customer_ref,
 cpd.product_seq,
  bci.contract_inst_id,
  bci.start_dat bci_start_dat,
  bci.end_dat bci_end_dat
FROM custproductdetails cpd, balcontractinstance bci
WHERE cpd.customer_ref = bci.customer_ref(+)
AND cpd.contract_seq = bci.contract_seq(+)
AND cpd.end_dat >=  bci.start_dat(+) AND cpd.end_dat <= bci.end_dat(+);


I need to write the above query without the (+) notation.

Thanks
Sunil

and Chris said...

To convert from Oracle syntax to ANSI, move all the join criteria into the join clause:

FROM custproductdetails cpd
LEFT JOIN balcontractinstance bci
ON  cpd.customer_ref = bci.customer_ref
AND cpd.contract_seq = bci.contract_seq
AND cpd.end_dat >=  bci.start_dat AND cpd.end_dat <= bci.end_dat
WHERE ...;

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Working

Sunil, October 31, 2017 - 12:04 pm UTC

Thanks. It worked out.

More to Explore

SQL

The Oracle documentation contains a complete SQL reference.