Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Best way for updating EVERY row in a large database?
Been there...
Sounds like you're using OCI or a precompiler but this should work for u. I've used it from PL/SQL many times. Oracle documents it, but points out that you lose most of the locking and read-consistency protection that you'll get when u open a cursor FOR UPDATE. The advantage is that you won't have to re-open the cursor after a commit. This will work for any cursor which fetches a rowid.
Hope this helps.
for csr in (
select rowid, col1, col2, ..... colN from mytab
/* do some stuff */ . . update mytab set .... where rowid = csr.rowid; commit work; /* u prob'ly won't do this after EVERY fetch */
end loop;
> This program is taking over 9 hours to run, and I am wondering if there is
> something I can do about that. I've looked into what I saw as the only
> viable alternative, and that is to use the WHERE CURRENT OF positioned
> cursor update instead of doing a separate UPDATE call for each fetched row.
> The problem with this approach is that, according to Oracle doc, you cannot
> fetch from the cursor anymore after you do a commit (you will get a 1002).
> I simply cannot update 3,000,000 rows without doing periodic commits.
>
> --
> Regards,
> Jim
--
The views expressed here are mine and do not reflect the official
position of my employer or the organization through which the
Internet was accessed.
Received on Thu Apr 23 1998 - 12:23:34 CDT
![]() |
![]() |