- 1、本文档共27页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
存储过程,函数,游标(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
您可能关注的文档
- 员工手册(The employee handbook).doc
- 品牌卖场--经销商的创新突围(Brand store - dealer innovation breakout).doc
- 品牌塑造的5A体系(Brand building 5A system).doc
- 品牌形象塑造的途径(The way that brand image is shaped).doc
- 哈利波特3游戏攻略(Harry potter 3 game strategy).doc
- 品质英语2(Quality English 2).doc
- 哈大齐工业走廊大庆区域发展规划(Regional development planning of daqing industrial corridor).doc
- 哈尔滨工业大学IP段分布(Distribution of IP section of Harbin institute of technology).doc
- 哈工大附近的公交车线路(一区和二区)(Bus routes near Harbin institute of technology (district 1 and 2)).doc
- 哈尔滨桥塌(Harbin bridge collapse).doc
- 答案基础知识水平技能模块纸中博f6uk dec.pdf
- 成果william h mcraven知识点结文WilliamH Mcraven.pdf
- 此内容已从iopscience向下滚动以查看全文tmrice epl 011.pdf
- diet节菜肴人会相信健康ufc holiday dishes04 Ufcdolce饮食假.pdf
- crs全球征税背景下大陆高净值人士财产隐身与税务筹划攻略土豪必读.pdf
- 浙江联合利华俱乐部大三二面大二.pdf
- 冬季假期阅读级单词计数访问各级别级本书.pdf
- 在洪水力系数上开口端短长度挤压电影阻尼器从理论到练习后背gt2017-63152.pdf
- 该由印刷页面空白页一个报告组成.pdf
- sigma-a4978共aldrich安全数据表.pdf
文档评论(0)