Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Using UPDATE with ROWNUM?

Using UPDATE with ROWNUM?

From: <darrenk_at_yahoo.com>
Date: Tue, 26 Jun 2007 08:54:01 -0700
Message-ID: <1182873241.073219.269420@n2g2000hse.googlegroups.com>


Hi,
I have a production tablespace with millions of rows. I need to set sequence values in each row but I can not lock the table for any more than 5 seconds.
I created SEQUENCE named tempseq and found that I can update 1000 rows in a short enough time.

Here is the script I tested. I have tested it but I don't understand how each row (from the SELECT) is getting processed only once, or if this script even guarantees that this will happen.

If someone can explain how ROWNUM is working in this UPDATE then that would help me.
Alternative solutions (that don't involve explicit cursors) are also welcome.

begin

	loop
		update (select seq_no from mytable) set seq_no = tempseq.nextval
where rownum <= 1000;
		exit when SQL%FOUND = false;
		commit;
	end loop;

end;

TIA
-Darren Received on Tue Jun 26 2007 - 10:54:01 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US