`
kb5706
  • 浏览: 41186 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论

WHERE CURRENT OF

 
阅读更多
如果你想删除或者更新被Select For Update引用的记录,你可以使用Where Current Of语句。


UPDATE table_name
    SET set_clause
    WHERE CURRENT OF cursor_name;
OR
DELETE FROM table_name
WHERE CURRENT OF cursor_name;




Where Current Of语句允许你更新或者是删除最后由cursor取的记录。


下面一个使用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;


分享到:
评论

相关推荐

    精髓Oralcle讲课笔记

    --------------------------------------------------having函数对于group by函数的过滤 不能用where-------------------------------------- 58、select deptno, avg(sal) from emp group by deptno having avg...

    关于游标使用sql

    CURRENT OF c_test_main; --填充下一条数据. FETCH NEXT FROM c_test_main INTO @id, @value; END; --关闭游标 CLOSE c_test_main; --释放游标. DEALLOCATE c_test_main; END; go ONE (1行...

    SQL sever 实训

    WHERE Customer.CusNO=Proout.CusNo AND Product.ProNO=Proln.ProNo AND Product.ProNO=Proout.ProNo AND Proout.Quantity=Proln.Quantity GO --创建视图V-Sale2,统计每种产品的销售数量和销售金额。统计结果包括...

    MySQL 数据库对服务器端光标的限制

    未实施UPDATE WHERE CURRENT OF和DELETE WHERE CURRENT OF,这是因为不支持可更新的光标。 光标是不可保持的(提交后不再保持打开)。 光标是不敏感的。 光标是不可滚动的。 光标是未命名的。语句处理程序起着光标ID...

    A review of remote sensing of chlorophyll-a concentration in coastal waters

    The scale effect problem arises during the modeling procedure where unrealistic homogeneous assumption is taken to measure chlorophyll-a concentration from the realistic non-homogeneous pixel....

    Management of Information Security, 6th Edition (PART 2)

    MANAGEMENT OF INFORMATION SECURITY, Sixth Edition prepares you to become an information security management practitioner able to secure systems and networks in a world where continuously emerging ...

    Handbook of Big Data Technologies

    Management and Analysis of Big Graph Data: Current Systems and Open Challenges 1 Introduction 2 Graph Databases 3 Graph Processing 4 Graph Dataflow Systems 5 Gradoop 6 Comparison 7 Current Research ...

    Augmented Reality Where We Will All Live / by Jon Peddie

    Augmented Reality: Where We Will All Live can be used as a comprehensive guide to the field of AR and provides valuable insights for technologists, marketers, business managers, educators and ...

    A Survey of Fault Tolerant Methodologies for FPGAs

    This survey attempts to provide an overview of the current state of the art for fault tolerance in FPGAs. It is assumed that faults have been previously detected and diagnosed; the methods ...

    A Survey of FPGA-Based LDPC Decoders

    design and presents an extensive review of the current literature. In-depth comparisons are drawn amongst 140 published designs (both academic and industrial) and the associated performance trade-offs...

    Management of Information Security, 6th EditionB (PART 1)

    MANAGEMENT OF INFORMATION SECURITY, Sixth Edition prepares you to become an information security management practitioner able to secure systems and networks in a world where continuously emerging ...

    On-line Pricing of Secondary Spectrum Access with Unknown Demand Function and Call Length Distribution

    are admitted and priced according to current availability of excess spectrum. Secondary users accept an advertised price with a certain probability defined by an underlying demand function. We analyze...

    Applications of MATLAB in Science and Engineering

    The book consists chapters illustrating a wide range of areas where MATLAB tools are applied. Many interesting problems have been included throughout the book, and its contents will be beneficial for ...

    Apache Hadoop 3.x state of the union and upgrade guidance

    The HDFS team is currently driving the Ozone initiative, which lays the foundation of the next generation of storage architecture for HDFS where data blocks are organized in storage containers for ...

    Interactive transport of multi-view videos for 3DTV applications

    only a selected number of views required for rendering video from its current viewpoint at any given time. The set of selected videos changes in real time as the user’s viewpoint changes because of ...

    PHP PDOStatement::setAttribute讲解

    PDOStatement::setAttribute ...说明 语法 bool PDOStatement::setAttribute ( int $attribute..._PDO::ATTR_CURSORNAME (Firebird 和 ODBC 特性): 为 UPDATE … WHERE CURRENT OF 设置游标名称。 返回值 成功时返回 T

    PHP PDOStatement::getAttribute讲解

    PDOStatement::getAttribute ...说明 ...PDO::ATTR_CURSOR_NAME (Firebird 和 ODBC 特性): 获取 UPDATE … WHERE CURRENT OF 的游标名称。 返回值 返回属性值。 总结 以上就是这篇文章的全部内容了

    大数据分析前沿

    Methods for including humans in the data-analysis loop through means such as crowdsourcing, where humans are used as a source of training data for learning algorithms, and visualization, which not ...

    发电机常用英文.pdf

    Annunciators are typically used in applications where the equipment monitored is not located in a portion of the facility that is normally attended. The NFPA has specific requirements for remote ...

    Vector Control of Three-Phase AC Machines: System Development in the Practice

    Main focus is on the application of the IM and the PMSM in electrical drive systems, where the method of the field-orientated control has been successfully established in the practice, and on the use...

Global site tag (gtag.js) - Google Analytics