Home >> FAQs/Tutorials >> Oracle Tutorials

Oracle Tutorials - Error: Single-Row Subquery Returns More Than One Row

By: FYIcenter.com

(Continued from previous topic...)

What Happens If the UPDATE Subquery Returns Multiple Rows?

If a subquery is used in a UPDATE statement, it must return exactly one row for each row in the update table that matches the WHERE clause. If it returns multiple rows, Oracle server will give you an error message. To test this out, you can try the following tutorial exercise:

UPDATE fyi_links SET (notes, created) = 
  (SELECT last_name, hire_date FROM employees
    WHERE employee_id < id)
  WHERE id < 110;
ERROR at line 1:
ORA-01427: single-row subquery returns more than one row

The problem is the criteria in the subquery: "employee_id < id"

(Continued on next topic...)

  1. What Are DML Statements?
  2. How To Create a Testing Table?
  3. How To Set Up SQL*Plus Output Format?
  4. How To Insert a New Row into a Table?
  5. How To Specify Default Values in INSERT Statement?
  6. How To Omit Columns with Default Values in INSERT Statement?
  7. How To Insert Multiple Rows with One INSERT Statement?
  8. How To Update Values in a Table?
  9. How To Update Values on Multiple Rows?
  10. How To Use Existing Values in UPDATE Statements?
  11. How To Use Values from Other Tables in UPDATE Statements?
  12. What Happens If the UPDATE Subquery Returns Multiple Rows?
  13. How To Delete an Existing Row from a Table?
  14. How To Delete Multiple Rows from a Table?
  15. How To Delete All Rows from a Table?

Oracle Tutorials:


Other Tutorials/FAQs:


Related Resources:


Selected Jobs: