在数据库里的一张表上加了一个字段,写一个存储过程,给原来的每条记录以递增的数据更新给刚加的这一个字段,存储过程怎么写啊?
create table TBL_INFO
(
SQH CHAR(13) not null,
DORDER NUMBER
)
create or replace procedure dorder_update is
result NUMBER(10);
cursor curs is
select t.sqh, t.dorder from tbl_info t Order By t.bfsj Desc;
d_order tbl_info.dorder%type;
d_sqh tbl_info.sqh%type;
begin
result := 0;
open curs;
loop
fetch curs into d_sqh, d_order;
exit when curs%notfound;
result := result + 1;
update tbl_info t set t.dorder = result where t.sqh=d_sqh;
end loop;
close curs;
end dorder_update;
create table TBL_INFO
(
SQH CHAR(13) not null,
DORDER NUMBER
)
create or replace procedure dorder_update is
result NUMBER(10);
cursor curs is
select t.sqh, t.dorder from tbl_info t Order By t.bfsj Desc;
d_order tbl_info.dorder%type;
d_sqh tbl_info.sqh%type;
begin
result := 0;
open curs;
loop
fetch curs into d_sqh, d_order;
exit when curs%notfound;
result := result + 1;
update tbl_info t set t.dorder = result where t.sqh=d_sqh;
end loop;
close curs;
end dorder_update;