sql - Conversion of legacy outer join to ANSI -


i have come across following legacy pl/sql , find outer joins against scalar constants confusing. first of all, can please confirm attempt convert ansi correct.

legacy code:

cursor c1item (c1item_iel_id number)   select     `<columns>`    iel_item iit, iel_item_property iip     iit.iit_change_type = 'i'     ,   iip.iip_change_type (+) = 'i'     ,   iip.it_id (+)  = iit.it_id     ,   iit.iel_id = c1item_iel_id     ,   iip.iel_id (+) = c1item_iel_id; 

ansi code

cursor c1item (c1item_iel_id number)   select      `<columns>`    iel_item iit   left outer join iel_item_property iip   on  iip.it_id = iit.it_id       ,  iit.iit_change_type = 'i'       ,  iip.iip_change_type = 'i'       ,  iit.iel_id = c1item_iel_id       ,  iip.iel_id = c1item_iel_id; 

if correct, don't see point of using outer join. surely if primary key it_id in table iit not have corresponding foreign key in table iip both iip.iit_change_type , iip.iel_id null, in case filtered out , clauses. why not use inner join? missing something? or original code nonsense?

no, it's not correct -- marked "(+)" need in left join, rest clause:

   select `<columns>`        iel_item iit   left join iel_item_property iip  on iip.it_id = iit.it_id                                   , iip.iip_change_type = 'i'                                   , iip.iel_id = c1item_iel_id     iit.iit_change_type = 'i'             , iit.iel_id = c1item_iel_id   

placement matters outer joins -- criteria in on clause applied before join, while criteria in applied after join. can affect result set returned, depends on data , setup. placement doesn't matter inner joins - in or on clause, result set same.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -