UPdate table column + PL/SQL

Hi, I have a question, I have an update query that listed below. It give me an error : 'single-row subquery returns more than one row." Can anyone give me an hint why?

UPDATE table1 SET SVC_CD = 'ABC'
      where BD_NR = (
            select A.NVP_BID_NR from table1  A, table2  B WHERE A.FG_NR = B.FG_NR
              AND A.BD_NR = B.BD_NR
                         AND A.C_CD = 'OU' )
chenjhuaAsked:
Who is Participating?
 
Jinesh KamdarConnect With a Mentor Commented:
That's because ur inner SELECT query returned more than 1 row for a single row of the table being updated. Since Oracle found multiple rows returned, it couldn't have updated the source table correctly and hence, threw the exception.
0
 
Jinesh KamdarConnect With a Mentor Commented:
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.
0
 
johnsoneConnect With a Mentor Senior Oracle DBACommented:
I think that you should have IN and not = with the sub-query.
0
All Courses

From novice to tech pro — start learning today.