Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 
 

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

Oracle Error Tips by Burleson Consulting (S. Karam)

 

The Oracle docs note this on the ORA-01427 error*:

ORA-01427 single-row subquery returns more than one row
 
Cause: The outer query must use one of the keywords ANY, ALL, IN, or NOT IN to specify values to compare because the subquery returned more than one row.
 
Action: Use ANY, ALL, IN, or NOT IN to specify which values to compare or reword the query so only one row is retrieved.

On Oracle Server and PL/SQL User Forum, Adam Wilbur received an ORA-01427 error code and received this information:

Question

Posted by 'Adam Wilbur' on April 21, 2001 at 20:37:00 EST:

Here's what I am trying to do...

UPDATE TABLEA SET TABLEA.COLUMN1 =
(select TABLEB.COLUMN1 FROM TABLEA, TABLEB
WHERE TABLEB.COLUMN2 = 'String Value'
AND TABLEA.COLUMN3 = TABLEB.COLUMN3
AND TABLEA.COLUIMN4 = TABLEB.COLUMN4
AND TABLEB.VALUENAME = 'String Value');


This query returns multiple rows, all of which I need to update in TABLEA.

How do I do this without getting ORA-01427 error?

Answer

Dmytro offered this advice to resolve ORA-01427:

Try to add and rownum=1 to your subquery conditions if you DO NOT care about the value from the list or DO sure that they are the same.

Single Row Subquery

A single row subquery returns only one row. It can be used with the equal comparison operators (=,<,>,<>, etc).

SQL> select
2 order_number
3 from
4 sales
5 where quantity = (select
6 max(quantity)
7 from
8 sales);

ORDER_NUMBER
--------------------
O161

Here, we get the order number for the order that contains the max quantity value. The outer query can return multiply rows, but the subquery can only return one row.

SQL> select
2 order_number
3 from
4 sales
5 where quantity > (select
6 avg(quantity)
7 from
8 sales);

ORDER_NUMBER
--------------------
O118
O149
O157
O161
O167
O179
O183
O186
O189
O193
O196
O197
O198
O199

14 rows selected.

Here, we want the order numbers where the order quantity is above the average quantity in the sales table. Notice that the subquery returns one and only one row that used in the filter.

 


Helpful Links:

You may want to refer to these helpful links concerning single and multi row subqueries, and tips on deleting rows while avoiding ORA-01427 by Don Burleson.


 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright ? 1996 -  2014

All rights reserved by Burleson

Oracle ? is the registered trademark of Oracle Corporation.


   

 

��  
 
 
 
 

 
 
 

 
 
Oracle performance tuning software 
 
oracle dba poster
Oracle Linux poster