Basic Oracle Concepts and Programming Question:
Download Job Interview Questions and Answers PDF
What Happens If the UPDATE Subquery Returns Multiple Rows?
Answer:
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 ggl_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"
UPDATE ggl_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"
Download Oracle Database Interview Questions And Answers
PDF
Previous Question | Next Question |
How To Use Values from Other Tables in UPDATE Statements using Oracle? | How To Delete an Existing Row from a Table in Oracle? |