Showing posts with label SQL Developer. Show all posts
Showing posts with label SQL Developer. Show all posts

Monday, October 23, 2017

Conditional OR joins in SQL query returns duplicate rows

Scenario: Whenever I have a particular OR condition join in my query, I get a duplicated record. The case is when the two join conditions before and after OR are satisfied.

SELECT A.Column1,A.Column2, Name, Address FROM A, B
WHERE (
(A.COLUMN1 = B.COLUMN1) OR (A.COLUMN2  = B.COLUMN2)
)

Cause: Imagine there are rows in A and B that satisfy the two join conditions used in OR, In such a scenario the database will return two rows with same value.


Here as per the query, for row 'Athul' in Table A, both the join conditions match with B and hence will return below output resultset,



As you can see in the result above, 'Athul' is resulted twice.  However for the second recrod

Solution: This can be avoided by using a LEFT join instead of an OR join condition. Do not consider using DISTINCT as it is a fairly cost consuming alternative.

Saturday, August 22, 2015

[Solved] Oracle SQL Developer JVM not Found Error

Scenario: Setting up Oracle SQL Developer for the first time from inside Database home. The first time you try to run SQLDeveloper.exe you will be prompted for a JDK bin path. 

At this step you might face an error as below,

Unable to find Java Virtual Machine error
Cause: The java path defined is a 64bit JDK.

Resolution: Install a new 32bit JDK and then open the sqldeveloper.conf file from app/product/dbhome_1/sqldeveloper/sqldeveloper/bin and delete the JAVA_HOME entry as below,

Changing JavaHome path
After deleting run the SQLDeveloper.exe file and again you will be prompted for a JDK bin path. Now give the path to the new 32bit JDK you just installed. This will make SQLDeveloper run in your machine.