Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

from ansi sql to oracle sql

Posted on 2011-09-02
7
Medium Priority
?
374 Views
Last Modified: 2012-05-12
we have inherted some code from another depratment,and we need to convert it to oracle from ansi we have done this alot before ,but this one is confusing because we have too many (( and )) and we do not really know how they affect the from and where clause,
please advise.

thanks


    FROM    (  (  (  ( subj

                         LEFT JOIN
                            (   care_inc
                             LEFT JOIN
                                (   v_mat
                                 LEFT JOIN
                                    MATERIAL
                                 ON v_mat.MATERIAL_ID =
                                       MATERIAL.MATERIAL_ID)
                             ON (care_inc.one_ID =
                                    v_mat.one_ID)
                                AND care_inc.care_seq =
                                       v_mat.care_seq)
                         ON (subj.care_seq =
                                care_inc.care_seq)
                            AND (subj.one_ID =
                                    care_inc.one_ID))
                     LEFT JOIN
                        one
                     ON subj.one_ID = one.one_ID)
                 LEFT JOIN
                    BASIC_MODULE_one_INFO
                 ON (subj.MODULE_ID =
                        BASIC_MODULE_one_INFO.MODULE_ID)
                    AND (subj.care_seq =
                            BASIC_MODULE_one_INFO.care_seq)
                    AND (subj.one_ID =
                            BASIC_MODULE_one_INFO.one_ID))
             LEFT JOIN
                one_FACILITY_INFO
             ON (care_inc.FACILITY_ID =
                    one_FACILITY_INFO.FACILITY_ID)
                AND (care_inc.one_ID =
                        one_FACILITY_INFO.one_ID))
         LEFT JOIN
            PERSON
         ON subj.worker_TEXT = PERSON.FULL_NAME
 
0
Comment
Question by:it-rex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 36473522
why convert?  Oracle supports ANSI joins since 9i

and the extra ()  aren't doing anythig, you can remove them
0
 
LVL 11

Author Comment

by:it-rex
ID: 36473532
management wants to convert all sql to oracle sql as they more readable and understandable..
not my choice.
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 36473554
I'd keep it like this...

SELECT *
  FROM subj
      LEFT JOIN care_inc
          ON subj.care_seq = care_inc.care_seq AND subj.one_id = care_inc.one_id
      LEFT JOIN v_mat
          ON care_inc.one_id = v_mat.one_id AND care_inc.care_seq = v_mat.care_seq
      LEFT JOIN material
          ON v_mat.material_id = material.material_id
      LEFT JOIN one
          ON subj.one_id = one.one_id
      LEFT JOIN basic_module_one_info
          ON     subj.module_id = basic_module_one_info.module_id
             AND subj.care_seq = basic_module_one_info.care_seq
             AND subj.one_id = basic_module_one_info.one_id
      LEFT JOIN one_facility_info
          ON care_inc.facility_id = one_facility_info.facility_id
             AND care_inc.one_id = one_facility_info.one_id
      LEFT JOIN person
          ON subj.worker_text = person.full_name



but if you're force too

SELECT *
  FROM subj,
       care_inc,
       v_mat,
       material,
       one,
       basic_module_one_info,
       one_facility_info,
       person
 WHERE     subj.care_seq = care_inc.care_seq(+)
       AND subj.one_id = care_inc.one_id(+)
       AND care_inc.one_id = v_mat.one_id(+)
       AND care_inc.care_seq = v_mat.care_seq(+)
       AND v_mat.material_id = material.material_id(+)
       AND subj.one_id = one.one_id(+)
       AND subj.module_id = basic_module_one_info.module_id(+)
       AND subj.care_seq = basic_module_one_info.care_seq(+)
       AND subj.one_id = basic_module_one_info.one_id(+)
       AND care_inc.facility_id = one_facility_info.facility_id(+)
       AND care_inc.one_id = one_facility_info.one_id(+)
       AND subj.worker_text = person.full_name(+)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 11

Author Comment

by:it-rex
ID: 36473695
sdstuber;
I thought that we only outer using (+) whenever we see "on";
but if there is "and" we show the join as is without (+),
please advise
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 36473716
no,

if you do this...


AND x.col1 = y.col1(+)
and x.col2 = y.col2

that's the same thing as...

ON x.col1 = y.col
WHERE x.col2 = y.col2

which is the same thing as...

AND x.col1 = y.col1
AND c.col2=y.col2

which is an inner join

in order to do outer joins you must put the (+) on ALL references to the outer joined table in the where clause



0
 
LVL 11

Author Comment

by:it-rex
ID: 36473735
your works,you are the man.
0
 
LVL 11

Author Closing Comment

by:it-rex
ID: 36473739
great
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question