网站大量收购独家精品文档,联系QQ:2885784924

存储过程,函数,游标(Stored procedures, functions, cursors).doc

存储过程,函数,游标(Stored procedures, functions, cursors).doc

  1. 1、本文档共27页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
存储过程,函数,游标(Stored procedures, functions, cursors)

存储过程,函数,游标(Stored procedures, functions, cursors) A, the cursor The cursor is a PL/SQL control structure that can be explicitly controlled for the processing of SQL statements to facilitate the processing of the data of the table. Ps. When the amount of data in the table is large, it is not recommended to use cursors (inefficient and resource-consuming), but it can be flexible with the data method. The cursor is a recorded pointer, which is fed back to the record of the table by using the cursor to update or delete the activity set. Cursor properties: % FOUND, % NOTFOUND, % ROWCOUNT, % ISOPEN 1. Explicit cursors An explicit cursor is a cursor that is explicitly declared by the user. Depending on the query defined in the cursor, the returned row set can contain zero or more rows, which are called activity sets. The cursor will point to the activity concentration. Explicit cursor manipulation: declare, open, retrieve records from cursor, and close. The SET SERVEROUTPUT ON. DECLARE CURSOR cur IS SELECT * FROM books. Myrecord books % ROWTYPE; The BEGIN The OPEN cur; LOOP The FETCH cur INTO books; EXIT the WHEN cur % NOTFOUND; Dbms_outout.put_line (book.id | | | | books. END LOOP; The CLOSE cur; The END; 1.1. Explicit cursor with parameters: parameters need not specify length or precision. 1.2. FOR circular cursor: use traversal mode to open, extract and close cursors automatically. (can you use % ROWCOUNT to get the number of rows extracted from the cursor?) DECLARE / * define the parameter cursor * / CURSOR cur_para varchar2 (id) IS SELECT books_name FROM books WHERE books_id = id; BGEIN / * call the parameter cursor and handle * / with a FOR loop FOR cur IN cur_para ( 0001 ) LOOP DBMS_OUTPUT. PUT_LINE (cur. Books_id | | | | cur. Books_id); END LOOP; The END; 1.3, use the display cursor to delete or update the record Definition: use SELECT... FOR UPDATE statement to indicate the lock of things; When executed: use the WHERE CURRENT OF curXXX clause to specify the cursor

您可能关注的文档

文档评论(0)

f8r9t5c + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8000054077000003

1亿VIP精品文档

相关文档