Home » SQL & PL/SQL » SQL & PL/SQL » how do i create an updatable cursor
how do i create an updatable cursor [message #36163] Thu, 08 November 2001 06:03 Go to next message
Srinivas
Messages: 138
Registered: June 2000
Senior Member
Hi,
I have a cursor and i am looping it,
for every loop,i want to update that cursor( the current record).

how do i create a updatable cursor and how do i use it.

Any help is appreciated.

Srinivas

----------------------------------------------------------------------
Re: how do i create an updatable cursor [message #36167 is a reply to message #36163] Thu, 08 November 2001 07:40 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Option 1 (pre-lock all the rows):

for r in (select * from t for update) loop
update t
set c = 'something'
where current of r;
end loop;

Option 2 (no pre-locking):

for r in (select t.*, rowid from t) loop
update t
set c = 'something'
where rowid = r.rowid;
end loop;

----------------------------------------------------------------------
Re: how do i create an updatable cursor [message #36187 is a reply to message #36163] Thu, 08 November 2001 22:44 Go to previous message
homer
Messages: 17
Registered: October 2001
Junior Member
An advice:
visit http://oradoc.photo.net

----------------------------------------------------------------------
Previous Topic: Global variable in Stored Procedure
Next Topic: Re: SQLPLUS Copy Command
Goto Forum:
  


Current Time: Thu May 23 17:40:13 CDT 2024