Oracle 更新或者删除游标行
2017-03-21 14:00
260 查看
-- 更新或删除游标行
/*注:当使用游标更新或者删除游标时,定义游标必须带有for update子句,在执行更新或者删除游标时必须带有 where current of 子句*/
-- 例:更新游标行
declare
cursor e_cursor is
select * from tg_test_user for update;
dno int :=&no;
begin
for e_record in e_cursor loop
if e_record.tg_test_userid = dno then
dbms_output.put_line('用户名:'||e_record.tg_test_username||',密码:'||e_record.tg_test_password||',ID:'||e_record.tg_test_userid);
update tg_test_user set tg_test_username='chao'where current of
e_cursor;
end if;
end loop;
end;
--删除游标行
declare
cursor e_cursor is select * from tg_test_user for update;
names varchar2(225):=lower('&name');
begin
for e_record in e_cursor loop
if lower(e_record.tg_test_username)= names then
null;
delete from tg_test_user where current of
e_cursor;
else
dbms_output.put_line('用户名:'||e_record.tg_test_username||',密码:'||e_record.tg_test_password||',ID:'||e_record.tg_test_userid);
end if;
end loop;
end;
/*注:当使用游标更新或者删除游标时,定义游标必须带有for update子句,在执行更新或者删除游标时必须带有 where current of 子句*/
-- 例:更新游标行
declare
cursor e_cursor is
select * from tg_test_user for update;
dno int :=&no;
begin
for e_record in e_cursor loop
if e_record.tg_test_userid = dno then
dbms_output.put_line('用户名:'||e_record.tg_test_username||',密码:'||e_record.tg_test_password||',ID:'||e_record.tg_test_userid);
update tg_test_user set tg_test_username='chao'where current of
e_cursor;
end if;
end loop;
end;
--删除游标行
declare
cursor e_cursor is select * from tg_test_user for update;
names varchar2(225):=lower('&name');
begin
for e_record in e_cursor loop
if lower(e_record.tg_test_username)= names then
null;
delete from tg_test_user where current of
e_cursor;
else
dbms_output.put_line('用户名:'||e_record.tg_test_username||',密码:'||e_record.tg_test_password||',ID:'||e_record.tg_test_userid);
end if;
end loop;
end;
相关文章推荐
- Oracle 参数 游标[游标更新删除数据]
- Oracle 10g使用游标更新或删除数据
- oracle删除或者更新了表里面的数据…
- Oracle 参数 游标[游标更新删除数据]|转|
- Oracle 10g使用游标更新或删除数据
- oracle游标的更新与删除数据
- Oracle 参数 游标[游标更新删除数据]
- Oracle 数据库更新或者删除之后,怎样恢复之前的数据
- Oracle 参数 游标[游标更新删除数据]
- 如何分析oracle表是否被人删除或者更新过?
- Oracle中merge into的使用:该命令使用一条语句从一个或者多个数据源中完成对表的更新和插入数据.
- oracle 游标循环删除表数据 sql
- 已更新或者删除的行值要么不能使该行成为唯一行,要么改变了多个行
- Oracle PL/SQL开发基础(第十二弹:插入、更新和删除)
- Mysql删除或者更新出错 Error Code: 1175. You are using safe update
- oracle更新大量数据太慢,可以通过游标实现的例子
- Oracle“记录被另一个用户锁住” 无法更新删除的解决办法
- 循环逐条修改或者删除数据(游标)
- Mybatis批量增加,删除,更新Oracle
- 恢复ORACLE被误更新或删除数据的方法