Sureshy
03-24-2006, 07:51 AM
Hi,
I have 5000 row table. One of the columns in the table called tansactionno has no data in it.
I want to create a sequence in that column starting at 10000 and ending at 15000. So each record has a unique identifier.
i tried to create an anoynmous block using a cursor to select each record and update the transactionno with a variable, 1 is then added to the variable and the whole thing loops until 5000 records have been fetched.
Unfortunately I am not a PL/SQL expert so am failing miserably with this.
here is what I have so far.. can someone please help me correcting it. Your help is much appreciated!!!
DECLARE
x int;
CURSOR csp_val_cur is
select * from csp_temp_scy;
csp_val_rec csp_val_cur%ROWTYPE;
BEGIN
x:=10000;
OPEN csp_val_cur;
LOOP
FETCH csp_val_cur into csp_val_rec;
EXIT WHEN NOT csp_val_cur%FOUND;
update csp_temp_scy
set transactionno = x;
x:=x+1;
END LOOP;
commit;
CLOSE csp_val_cur;
end;
I have 5000 row table. One of the columns in the table called tansactionno has no data in it.
I want to create a sequence in that column starting at 10000 and ending at 15000. So each record has a unique identifier.
i tried to create an anoynmous block using a cursor to select each record and update the transactionno with a variable, 1 is then added to the variable and the whole thing loops until 5000 records have been fetched.
Unfortunately I am not a PL/SQL expert so am failing miserably with this.
here is what I have so far.. can someone please help me correcting it. Your help is much appreciated!!!
DECLARE
x int;
CURSOR csp_val_cur is
select * from csp_temp_scy;
csp_val_rec csp_val_cur%ROWTYPE;
BEGIN
x:=10000;
OPEN csp_val_cur;
LOOP
FETCH csp_val_cur into csp_val_rec;
EXIT WHEN NOT csp_val_cur%FOUND;
update csp_temp_scy
set transactionno = x;
x:=x+1;
END LOOP;
commit;
CLOSE csp_val_cur;
end;