Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

from ansi sql to oracle sql

Posted on 2011-09-02
7
Medium Priority
?
376 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
  • 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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

824 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