Monday, April 19, 2010

ORA-01427: single-row subquery returns more than one row

I faced today, "ORA-01427:sub-query returns more than one row" error. The problem is easy to identify:This error is raised, when a sub-query returns more than one row to an Equality or in-Equality operator. The reason being there are restrictions on the legal comparison operators (Screen -1).


For any comparison operator listed in the table shown below, the sub-query must return single row (in other words, the sub-query, must be a single-row sub-query, otherwise it will fail)
Single-row Sub-query Operators
Symbol Meaning
= equal
> greater than
>= greater than or equal
< less than
<= less than or equal
<> not equal
!= not equal

The operators in the following table can use multiple-row sub-queries:
Multiple-row Sub-query Operators
Symbol Meaning
IN equal to any member in a list
NOT IN not equal to any member in a list
ANY returns rows that match any value on a list
ALL returns rows that match all the values in a list

There are several approaches to resolve this, most popular one being changing the inequality operator to a multiple-row operators (say, if the operator is "=" than change it "IN", "ANY", "ALL", so that it does not matter if multiple rows are returned.).
However, I found that if you use inline views, you can retain inequality operator as shown below in (Screen -2)
Note: In order to get consistent result, use the sub-query based on primary key. The above method is based on unique key

How to open linux folders in the same window?

Default behavior while opening folders in Linux, meant, a new window for each folder I double-clicked on. To prevent that, and to ensure Linux opens folders in the same window, I followed the steps listed below:
Go to home folder (Screen -1)
Select Edit from the Menu and scroll down to click on Preferences (Screen -2)

Click on Behavior Tab and select "Always open in browser window" (Screen -3)

The explorer view is shown below (Screen -4)