If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > your opinion on this sql please

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-08-04, 13:45
ericksob ericksob is offline
Registered User
 
Join Date: Aug 2003
Location: MN
Posts: 10
your opinion on this sql please

using oracle 9.2

I'm converting a statement using the left outer join symbol (+) in the WHERE clause, to the ANSI standard method doing the join in the FROM clause.

I'm I doing this convertion right?
It just seems way too convoluted.
--------------------------------------------------
select count(mmatter)
from ware.matter,
(select udvalue,udjoin from ware.udf where udtype='MT' and udfindex=6) BrokDept,
(select udvalue,udjoin from ware.udf where udtype='MT' and udfindex=13) ProdCode,
(select uddate,udjoin from ware.udf where udtype='MT' and udfindex=11) ProjEndDt,
(select udvalue,udjoin from ware.udf where udtype='MT' and udfindex=10) RenewalDt
where matter.mmatter=BrokDept.udjoin(+) and
matter.mmatter=ProdCode.udjoin(+) and
matter.mmatter=ProjEndDt.udjoin(+) and
matter.mmatter=RenewalDt.udjoin(+);


Convert to...

select count(ware.matter.mmatter)
from (((ware.matter left outer join (select udvalue,udjoin from ware.udf where udtype='MT' and udfindex=6) BrokDept on matter.mmatter=BrokDept.udjoin)
left outer join (select udvalue,udjoin from ware.udf where udtype='MT' and udfindex=13) ProdCode
on matter.mmatter=ProdCode.udjoin)
left outer join (select uddate,udjoin from ware.udf where udtype='MT' and udfindex=11) ProjEndDt
on matter.mmatter=ProjEndDt.udjoin)
left outer join (select udvalue,udjoin from ware.udf where udtype='MT' and udfindex=10) RenewalDt
on matter.mmatter=RenewalDt.udjoin;
Reply With Quote
  #2 (permalink)  
Old 03-08-04, 20:07
r123456 r123456 is offline
Registered User
 
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
You should not need to have 4 inline views.

Select *
from tableA, tableB
where tableA.id = tableB.id (+);

is rewritten as:

Select *
from tableA ta
LEFT OUTER JOIN
tableB tb ON
ta.id = tb.id
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On