where current of 子句
2014-05-15 10:54
260 查看
PL/SQL提供为update和delete语句在cursor中使用提供了where current of子句。这个子句让你容易地进行update和delete操作对最近fetch的行进行操作。
语法:
UPDATE table_name
SET set_clause
WHERE CURRENT OF cursor_name;
DELETE
FROM table_name
WHERE CURRENT OF cursor_name
使用这个子句的作用主要是对上一次fetch的行进行update和delete操作,不需要在where条件中写=表达式,让where条件更简单,自动定位行。例子如下:
-- where current of cursor
declare
cursor cemp is
select * from employees for update;--要结合for update使用 vemp cemp%rowtype;
begin
open cemp;
loop
fetch cemp into vemp;
exit when cemp%notfound;
update employees set salary=salary*1.2 where current of cemp;--where current of
end loop;
commit;
close cemp;
end;
语法:
UPDATE table_name
SET set_clause
WHERE CURRENT OF cursor_name;
DELETE
FROM table_name
WHERE CURRENT OF cursor_name
使用这个子句的作用主要是对上一次fetch的行进行update和delete操作,不需要在where条件中写=表达式,让where条件更简单,自动定位行。例子如下:
-- where current of cursor
declare
cursor cemp is
select * from employees for update;--要结合for update使用 vemp cemp%rowtype;
begin
open cemp;
loop
fetch cemp into vemp;
exit when cemp%notfound;
update employees set salary=salary*1.2 where current of cemp;--where current of
end loop;
commit;
close cemp;
end;
相关文章推荐
- Oracle/PLSQL: WHERE CURRENT OF Statement
- WHERE CURRENT OF
- PLSQL中对cursor的where current of 的使用例子
- Oracle/PLSQL: WHERE CURRENT OF Statement
- Oracle/PLSQL: WHERE CURRENT OF Statement
- Oracle游标之select for update和where current of 语句
- where current of语句
- WHERE CURRENT OF
- Oracle/PLSQL: WHERE CURRENT OF Statement
- for update 与where current of的问题
- Oracle/PLSQL: WHERE CURRENT OF Statement
- PLSQL条件语句完成员工加薪功能(记录类型+游标case when+if+for update+where current of)
- 解决VS2010打开项目时“This project is incompatible with the current version of Visual Studio”
- pwd--print name of current/working directory
- A Summary of Current Machine Learning Frameworks
- 连接查询中where子句的执行
- Where can i download Android & iOS source code of TI BLE Multitool
- Updates were rejected because the tip of your current branch is behind
- MySQL的简单COUNT查询(无WHERE子句)
- Updates were rejected because the tip of your current branch is behind