有一个表叫t_user
字段 c_code 下有一些工号
如 1111 2222 3333 44444 08074926
还有个表 xht_111 空的。下边是个过程
declare
cursor aa is
select u.c_code as v_code from t_user u;
begin
savepoint a;
for data1 in aa loop
insert into xht_111 values(data1.v_code);
if data1.v_code='08074926' then
rollback to a;
end if;
end loop;
commit;
end;这个例子的构想是如果 c_code 有工号是08074926 的话,
那就应该回滚到初始啊~
为啥还是会插入数据呢
字段 c_code 下有一些工号
如 1111 2222 3333 44444 08074926
还有个表 xht_111 空的。下边是个过程
declare
cursor aa is
select u.c_code as v_code from t_user u;
begin
savepoint a;
for data1 in aa loop
insert into xht_111 values(data1.v_code);
if data1.v_code='08074926' then
rollback to a;
end if;
end loop;
commit;
end;这个例子的构想是如果 c_code 有工号是08074926 的话,
那就应该回滚到初始啊~
为啥还是会插入数据呢
cursor aa is
select rtrim(u.c_code) as v_code from t_user u;要不看看
select * from t_user where c_code = '08074926';是否可以返回记录。
--------------------
1111
2222
3333
44444
08074926SQL> select * from a06;no rows selectedSQL>
SQL>
SQL> select * from a05;C_CODE
--------------------
1111
2222
3333
44444
08074926SQL> select * from a06;no rows selectedSQL> declare
2 cursor aa is
3 select u.c_code as v_code from a05 u;
4 begin
5 savepoint a;
6 for data1 in aa loop
7 insert into a06 values (data1.v_code);
8 if data1.v_code = '08074926' then
9 rollback to a;
10 end if;
11 end loop;
12 commit;
13 end;
14 /PL/SQL procedure successfully completed.SQL> select * from a06;no rows selectedSQL>测试没问题。
楼上分析的在理
我又按照2楼朋友方式 重新测试下,还不可以是不是 需要什么命令开启事物回滚啊。。
4楼朋友
select * from t_user where c_code = '08074926';是可以返回记录的。。
用的是vchar2(255)
数据 111 222 44 08074926 33 555
过程之后 就是33 555
数据 111 222 44 33 555 08074926 过程之后 就无
字段如下
111
222
33
08074926
55
66
怎么样可以使08074926 排到最后一位呢