I ran into the following legacy PL / SQL and found that external joins with scalar constants were somewhat confusing. First of all, someone can confirm that my attempt to convert this to ANSI is correct.
LEGACY CODE :
cursor c1item (c1item_iel_id number) is select `<columns>` from iel_item iit, iel_item_property iip where iit.iit_change_type = 'I' and iip.iip_change_type (+) = 'I' and iip.it_id (+) = iit.it_id and iit.iel_id = c1item_iel_id and iip.iel_id (+) = c1item_iel_id;
ANSI CODE
cursor c1item (c1item_iel_id number) is select `<columns>` from iel_item iit left outer join iel_item_property iip on iip.it_id = iit.it_id and iit.iit_change_type = 'I' and iip.iip_change_type = 'I' and iit.iel_id = c1item_iel_id and iip.iel_id = c1item_iel_id;
If this is correct, I see no reason to use an external connection. Of course, if the primary key it_id in the iit table does not have a corresponding foreign key in the iip table, while iip.iit_change_type strong> and iip.iel_id will be NULL, in which case they will be filtered by AND clauses. So why not just use the inner join? Am I missing something? or is the original code error?
Johna
source share