Home » SQL & PL/SQL » SQL & PL/SQL » Update Statement
Update Statement [message #2181] Wed, 26 June 2002 05:51 Go to next message
Jzo
Messages: 4
Registered: June 2002
Junior Member
Hi! I'm trying to make an update statement,However, I would like to implement a SELECT statement in the SET clause of the UPDATE. How would I do that without getting the following error:
ORA-01427: single-row subquery returns more than one row.

basically what I want to do with this UPDATE is that I do not want to actually put the literal data in the UPDATE. I would like for the UPDATE to do this automatically by me using a SELECT statement.

this my UPDATE statement:

UPDATE student_course
SET sc_grade = (SELECT AVG(scg_item_grade)
FROM student,student_course_grade,student_course,course
WHERE s_ssn = sc_s_ssn
AND
student_course_id IN(sc_id)
AND
sc_course_number = course_number
Re: Update Statement [message #2182 is a reply to message #2181] Wed, 26 June 2002 06:36 Go to previous message
koteswara rao p.
Messages: 10
Registered: June 2002
Junior Member
hi
In your query there is one error.
the error is the subquery i.e select query
returning more than on rows.
the select query should return one row and only one
column.
because you are assigning the result to sc_grade.
try once again.

regards
koti
Previous Topic: plsql fuction
Next Topic: Create Function
Goto Forum:
  


Current Time: Fri Apr 19 06:37:26 CDT 2024