Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

making an update query through a subquery using ROW_NUMBER()?

PV SobrinhoSep 10 2015 — edited Sep 11 2015

This query does not work ERROR: 01427. 00000 - "single-row subquery returns more than one row":

I want to update the column values using the ROW_NUMBER () that is not a physical column.

enter image description here

enter image description here

enter image description here

This SELECT works perfectly. I want to copy the ROW_NUMBER () values for sequence_day_job column, in the same order

SELECT  column_person_id, column_day_job, sequence_day_job, ROW_NUMBER() OVER (PARTITION BY column_person_id ORDER BY column_day_job) FROM table_name;

UPDATE 10/09/2015 (01) - UPDATE tried to accomplish something like this, but it did not work, if a temporary table would solve my problem? It's something that seems to be relatively simple for the use of a temporary table, and cmo will be a recurring believe that use of temporary table is not so interesting.

 UPDATE PC_COMENTARIO SET COD_SEQUENCIA = ( SELECT ROW_NUMBER() OVER (PARTITION BY cod_processo ORDER BY dtc_andamento) FROM PC_COMENTARIO )WHERE cod_processo = 808;

//ERROR: 01427. 00000 - "single-row subquery returns more than one row"

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 9 2015
Added on Sep 10 2015
10 comments
2,184 views