Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Using UPDATE with ROWNUM?
Hasta wrote:
> In article <1183151689.328262_at_bubbleator.drizzle.com>,
> damorgan_at_psoug.org says...
>> Hasta wrote: >> >>> But why would the OP get ora-1555, Joel (and Frank and Daniel) ? >>> >>> He is not commiting in a cursor loop, afaics >>> >>> 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; >>> >>> --- Raoul >> Lets see: >> >> EXIT ... >> COMMIT ... >> END LOOP ... >> >> He isn't? >>
Literally you are correct and I will admit that I didn't look at the statement closely enough to see that you said "cursor loop" rather than loop.
But now, having looked at the statement very closely, I have another comment to make ... what is it that prevents the loop from updating the exact same 1000 rows ad infinitum?
CREATE TABLE test AS
SELECT object_id, created
FROM dba_objects;
CREATE SEQUENCE tempseq;
SELECT COUNT(*) FROM test;
SELECT COUNT(*) FROM test WHERE created > SYSDATE;
SQL> SELECT COUNT(*) FROM test
2 WHERE created > SYSDATE;
COUNT(*)
1000
SQL> SELECT last_number
2 FROM user_sequences
3 WHERE sequence_name = 'TEMPSEQ';
LAST_NUMBER
10001
SQL> That is 1000 rows updated 10 times ... not 10,000 rows updated.
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Group www.psoug.orgReceived on Sat Jun 30 2007 - 09:59:03 CDT
![]() |
![]() |