This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes Left-right outer join problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Left-right outer join problem" Watch "Left-right outer join problem" New topic
Author

Left-right outer join problem

Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 191
I have a query written in procedure as below



Here if admin is a condition i should join as c.id(+)=d.id else if it is a tester i have to join as c.id=d.id(+)

I am using PL/SQL procedure. This is a complex query with muliple joins.

I can duplicate the query and use this in procedure by putting query in IF-ELSE blocks. But due change in one line duplication is not correct.

Please suggest how to resolve.
Fatih Keles
Ranch Hand

Joined: Sep 01, 2005
Posts: 182
Hi Eshwar,

Do you need both "admin" and "tester" results in your cursor? If the answer is "No" than do not try write a fancy tricky sql query because:
1. it will mass up index usage if you have many joins and costly execution plan.
2. maintenance is difficult, each time you need to add something you will have to decode your fancy statements, understand it and re-implement it according to changing requirement.

Regards,

Fatih.
Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 191
so writing sql query with small change in if else block of proc would be most appropriate. Is that correct.
Fatih Keles
Ranch Hand

Joined: Sep 01, 2005
Posts: 182
I believe writing very complex sql statements that will handle any situation is not a good approach. I would prefer a bunch of simple cursors rather than one complex cursor.

Regards,

Fatih.
Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 191
Thanks i will follow your suggestion
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Left-right outer join problem
 
Similar Threads
Combining Multiple Inner Joins with a Left Join
Overriding rule for generics
accessing parent of child
which join to use?
Need to "simulate" multiple full outer joins on db2