Oracle/PLSQL: WHERE CURRENT OF Statement
来源:互联网 发布:手机清理缓存软件 编辑:程序博客网 时间:2024/05/29 18:25
Oracle/PLSQL: WHERE CURRENT OF Statement
If you plan on updating or deleting records that have been referenced by a Select For Update statement, you can use the Where Current Of statement.
译:如果你想删除或者更新被Select For Update引用的记录,你可以使用Where Current Of语句。
The syntax for the Where Current Of statement is either:
UPDATE table_name
SET set_clause
WHERE CURRENT OF cursor_name;
SET set_clause
WHERE CURRENT OF cursor_name;
OR
DELETE FROM table_name
WHERE CURRENT OF cursor_name;
WHERE CURRENT OF cursor_name;
The Where Current Of statement allows you to update or delete the record that was last fetched by the cursor.
译:Where Current Of语句允许你更新或者是删除最后由cursor取的记录。
Updating using the WHERE CURRENT OF Statement
Here is an example where we are updating records using the Where Current Of Statement:
译:下面一个使用Where Current Of更新记录的例子:
CREATE OR REPLACE Function FindCourse
( name_in IN varchar2 )
RETURN number
IS
cnumber number;
( name_in IN varchar2 )
RETURN number
IS
cnumber number;
CURSOR c1
IS
SELECT course_number, instructor
from courses_tbl
where course_name = name_in
FOR UPDATE of instructor;
BEGIN
IS
SELECT course_number, instructor
from courses_tbl
where course_name = name_in
FOR UPDATE of instructor;
BEGIN
open c1;
fetch c1 into cnumber;
if c1%notfound then
cnumber := 9999;
fetch c1 into cnumber;
if c1%notfound then
cnumber := 9999;
else
UPDATE courses_tbl
SET instructor = 'SMITH'
WHERE CURRENT OF c1;
UPDATE courses_tbl
SET instructor = 'SMITH'
WHERE CURRENT OF c1;
COMMIT;
end if;
close c1;
close c1;
RETURN cnumber;
END;
Deleting using the WHERE CURRENT OF Statement
Here is an example where we are deleting records using the Where Current Of Statement:
译:下面一个使用Where Current Of删除记录的例子:
CREATE OR REPLACE Function FindCourse
( name_in IN varchar2 )
RETURN number
IS
cnumber number;
( name_in IN varchar2 )
RETURN number
IS
cnumber number;
CURSOR c1
IS
SELECT course_number, instructor
from courses_tbl
where course_name = name_in
FOR UPDATE of instructor;
BEGIN
IS
SELECT course_number, instructor
from courses_tbl
where course_name = name_in
FOR UPDATE of instructor;
BEGIN
open c1;
fetch c1 into cnumber;
if c1%notfound then
cnumber := 9999;
fetch c1 into cnumber;
if c1%notfound then
cnumber := 9999;
else
DELETE FROM courses_tbl
WHERE CURRENT OF c1;
DELETE FROM courses_tbl
WHERE CURRENT OF c1;
COMMIT;
end if;
close c1;
close c1;
RETURN cnumber;
END;
- Oracle/PLSQL: WHERE CURRENT OF Statement
- Oracle/PLSQL: WHERE CURRENT OF Statement
- Oracle/PLSQL: WHERE CURRENT OF Statement
- Oracle/PLSQL: WHERE CURRENT OF Statement
- Oracle 游标的where current of子句
- WHERE CURRENT OF
- where current of 子句
- Oracle/PLSQL: Case Statement
- Oracle/PLSQL: Exit Statement
- Oracle/PLSQL: FETCH Statement
- Oracle/PLSQL: OPEN Statement
- Oracle / PLSQL: ALTER TABLE Statement
- PLSQL条件语句完成员工加薪功能(记录类型+游标case when+if+for update+where current of)
- Oracle游标之select for update和where current of 语句
- for update 与where current of的问题
- Secret of oracle logic IO: Current Mode
- PLSQL:Exit Statement
- 【技术支持】Oracle plsql中的having子句并非都能改写成where子句。having子句的适用场景。
- FCKeditor2.3 For PHP 参考
- VC++下使用ADO编写数据库程序
- Ext3 和 ext4 文件系统在线调整大小内幕
- Java Web 服务的通用部署
- 培训笔记二-sql数据库管理教程[改版+补充中]
- Oracle/PLSQL: WHERE CURRENT OF Statement
- On Failure-论失败
- 动易网站管理系统vote.asp页面存在SQL注入漏洞
- php 与 paradox7
- 清华大学教授称月收入万元是进入中产阶级起点
- 关于键盘控制菜单的问题
- 保持页面美观,同时使图片保持原比例缩小想法!
- Hibernate对多表关联查询
- JavaScript串口(通过vb的MSCOMM32.OCX控件)