博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Oracle/PLSQL WHERE CURRENT OF Statement
阅读量:5833 次
发布时间:2019-06-18

本文共 1791 字,大约阅读时间需要 5 分钟。

 
Oracle/PLSQL: WHERE CURRENT OF Statement
 
If you plan on updating or deleting records that have been referenced by a statement, you can use the Where Current Of statement.
译:如果你想删除或者更新被
引用的记录,你可以使用
Where Current Of
语句。
The syntax for the Where Current Of statement is either:
UPDATE table_name
    SET set_clause
    WHERE CURRENT OF cursor_name;
OR
DELETE FROM table_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;
    CURSOR c1
    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;
else
     UPDATE courses_tbl
        SET instructor = 'SMITH'
        WHERE CURRENT OF c1;
    COMMIT;
end if;
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;
    CURSOR c1
    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;
else
     DELETE FROM courses_tbl
        WHERE CURRENT OF c1;
    COMMIT;
end if;
close c1;
RETURN cnumber;
END;
 
 

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!

转载于:https://www.cnblogs.com/skiwdhwhssh/p/10342264.html

你可能感兴趣的文章
第一次作业 4班卢炳武
查看>>
const int * 与 int *const
查看>>
抽象类的调用
查看>>
libjpeg.a exists or that its path is correct
查看>>
实现可折叠的分组tableview
查看>>
android 资源管理之 Asset/raw 1
查看>>
使用硬盘,安装双系统,Win7+CentOS
查看>>
Javascript学习总结
查看>>
快速安装infobright
查看>>
如何设计一门语言(二)——什么是坑(b)
查看>>
【转】Mean shift 聚类分析
查看>>
JS 操作Excel格式
查看>>
隐藏专杀工具文件夹病毒专杀工具
查看>>
php 用正则替换中文字符一系列问题解决
查看>>
ActiveMQ应用笔记一:基本概念&安装
查看>>
Hibernate download
查看>>
防止 JavaScript 自动插入分号
查看>>
WPF MVVM实现TreeView
查看>>
C# 多态理解
查看>>
uboot启动阶段修改启动参数方法及分析
查看>>