6 个解决方案
#1
最简单的办法:自己写个程序加吧.
#2
oracle 中没有办法?
#3
修改表结构、建立序列,写一个存储过程
alter table t_1 add(id number);
create sequence s_1 increment by 1 start with 1 maxvalue 999999 minvalus 1;
create or replace procedure p_1 is
cursor cursor1 is select id from t_1 for update;
v_id cursor1.id%type
begin
for id_record in cursor1 loop
update t_1 set id=s_1.nextvalue;
end loop;
end;
没测试过,仅供参考
alter table t_1 add(id number);
create sequence s_1 increment by 1 start with 1 maxvalue 999999 minvalus 1;
create or replace procedure p_1 is
cursor cursor1 is select id from t_1 for update;
v_id cursor1.id%type
begin
for id_record in cursor1 loop
update t_1 set id=s_1.nextvalue;
end loop;
end;
没测试过,仅供参考
#4
修改一下上面的存储过程
create or replace procedure p_1 is
cursor cursor1 is select id from t_1 for update;
v_id cursor1.id%type
begin
loop
fetch cursor1 into v_id;
exit when cursor1%notfound;
if v_id is null then
update t_1 set id=s_1.nextvalue where current of cursor1;
end if;
end loop;
end;
create or replace procedure p_1 is
cursor cursor1 is select id from t_1 for update;
v_id cursor1.id%type
begin
loop
fetch cursor1 into v_id;
exit when cursor1%notfound;
if v_id is null then
update t_1 set id=s_1.nextvalue where current of cursor1;
end if;
end loop;
end;
#5
alter table t_1 add(id number);
create sequence seq_id increment by 1 start with 1 ;
update t_1 set id=seq_id.nextval;
commit;
create sequence seq_id increment by 1 start with 1 ;
update t_1 set id=seq_id.nextval;
commit;
#6
我是个新手,我不知道存储过程在那里运行,也不知道那些语句的意思,虽然我用oracle。
所以我想小声地问一下那个存储过程怎么用?
dacong(大聪)这位大哥的语句能在sqlplus 里运行。也成功。谢谢!
这是我在sqlplus中运行那个存储过程
SQL> create or replace procedure p_1 is
2 cursor cursor1 is select tenementid from tenement for update;
3 v_id cursor1.id%type (这句话不知道什么意思!)
4 begin
5 loop
6 fetch cursor1 into v_id;
7 exit when cursor1%notfound;
8 if v_id is null then
9 update tenement set tenementid sq_id.nextvalue where current of cursor1;
10 end if;
11 end loop;
12
13 end;
14 /
所以我想小声地问一下那个存储过程怎么用?
dacong(大聪)这位大哥的语句能在sqlplus 里运行。也成功。谢谢!
这是我在sqlplus中运行那个存储过程
SQL> create or replace procedure p_1 is
2 cursor cursor1 is select tenementid from tenement for update;
3 v_id cursor1.id%type (这句话不知道什么意思!)
4 begin
5 loop
6 fetch cursor1 into v_id;
7 exit when cursor1%notfound;
8 if v_id is null then
9 update tenement set tenementid sq_id.nextvalue where current of cursor1;
10 end if;
11 end loop;
12
13 end;
14 /
#1
最简单的办法:自己写个程序加吧.
#2
oracle 中没有办法?
#3
修改表结构、建立序列,写一个存储过程
alter table t_1 add(id number);
create sequence s_1 increment by 1 start with 1 maxvalue 999999 minvalus 1;
create or replace procedure p_1 is
cursor cursor1 is select id from t_1 for update;
v_id cursor1.id%type
begin
for id_record in cursor1 loop
update t_1 set id=s_1.nextvalue;
end loop;
end;
没测试过,仅供参考
alter table t_1 add(id number);
create sequence s_1 increment by 1 start with 1 maxvalue 999999 minvalus 1;
create or replace procedure p_1 is
cursor cursor1 is select id from t_1 for update;
v_id cursor1.id%type
begin
for id_record in cursor1 loop
update t_1 set id=s_1.nextvalue;
end loop;
end;
没测试过,仅供参考
#4
修改一下上面的存储过程
create or replace procedure p_1 is
cursor cursor1 is select id from t_1 for update;
v_id cursor1.id%type
begin
loop
fetch cursor1 into v_id;
exit when cursor1%notfound;
if v_id is null then
update t_1 set id=s_1.nextvalue where current of cursor1;
end if;
end loop;
end;
create or replace procedure p_1 is
cursor cursor1 is select id from t_1 for update;
v_id cursor1.id%type
begin
loop
fetch cursor1 into v_id;
exit when cursor1%notfound;
if v_id is null then
update t_1 set id=s_1.nextvalue where current of cursor1;
end if;
end loop;
end;
#5
alter table t_1 add(id number);
create sequence seq_id increment by 1 start with 1 ;
update t_1 set id=seq_id.nextval;
commit;
create sequence seq_id increment by 1 start with 1 ;
update t_1 set id=seq_id.nextval;
commit;
#6
我是个新手,我不知道存储过程在那里运行,也不知道那些语句的意思,虽然我用oracle。
所以我想小声地问一下那个存储过程怎么用?
dacong(大聪)这位大哥的语句能在sqlplus 里运行。也成功。谢谢!
这是我在sqlplus中运行那个存储过程
SQL> create or replace procedure p_1 is
2 cursor cursor1 is select tenementid from tenement for update;
3 v_id cursor1.id%type (这句话不知道什么意思!)
4 begin
5 loop
6 fetch cursor1 into v_id;
7 exit when cursor1%notfound;
8 if v_id is null then
9 update tenement set tenementid sq_id.nextvalue where current of cursor1;
10 end if;
11 end loop;
12
13 end;
14 /
所以我想小声地问一下那个存储过程怎么用?
dacong(大聪)这位大哥的语句能在sqlplus 里运行。也成功。谢谢!
这是我在sqlplus中运行那个存储过程
SQL> create or replace procedure p_1 is
2 cursor cursor1 is select tenementid from tenement for update;
3 v_id cursor1.id%type (这句话不知道什么意思!)
4 begin
5 loop
6 fetch cursor1 into v_id;
7 exit when cursor1%notfound;
8 if v_id is null then
9 update tenement set tenementid sq_id.nextvalue where current of cursor1;
10 end if;
11 end loop;
12
13 end;
14 /