By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,963 Members | 1,778 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,963 IT Pros & Developers. It's quick & easy.

procedure for numering records - no effect

P: n/a
Hi

I'm trying to add numers to "id" field in my "kadry" table. I write
procedure to do it (as follows) but running this procedure does make
no effect.
Where is bug?
best regards

D.T.

PROCEDURE KADRY_PROC_SEQ2
IS
BEGIN
declare
i number;
k number;
nazwisko varchar2(40);
cursor cur1 IS
select * from kadry;
BEGIN
k:=1;
for c1 IN cur1
loop
c1.id:=k;
k:=k+1;
end loop;
commit;
end;
END;
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Dariusz Tomon" <d.*****@mazars.pl> wrote in message
news:c7************************@posting.google.com ...
| Hi
|
| I'm trying to add numers to "id" field in my "kadry" table. I write
| procedure to do it (as follows) but running this procedure does make
| no effect.
| Where is bug?
| best regards
|
| D.T.
|
| PROCEDURE KADRY_PROC_SEQ2
| IS
| BEGIN
| declare
| i number;
| k number;
| nazwisko varchar2(40);
| cursor cur1 IS
| select * from kadry;
| BEGIN
| k:=1;
| for c1 IN cur1
| loop
| c1.id:=k;
| k:=k+1;
| end loop;
| commit;
| end;
| END;
welcome to SQL ;-)

this code only reads the KADRY table and resets a variable in memory -- if
you want to change a value in the database you need to use an UPDATE
statement

;-{ mcs
Jul 19 '05 #2

P: n/a
Jan
simple SQL is enough
UPDATE your_table
SET id =rownum;

COMMIT;
d.*****@mazars.pl (Dariusz Tomon) wrote in message news:<c7************************@posting.google.co m>...
Hi

I'm trying to add numers to "id" field in my "kadry" table. I write
procedure to do it (as follows) but running this procedure does make
no effect.
Where is bug?
best regards

D.T.

PROCEDURE KADRY_PROC_SEQ2
IS
BEGIN
declare
i number;
k number;
nazwisko varchar2(40);
cursor cur1 IS
select * from kadry;
BEGIN
k:=1;
for c1 IN cur1
loop
c1.id:=k;
k:=k+1;
end loop;
commit;
end;
END;

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.