{"id":15753,"date":"2023-12-04T22:16:21","date_gmt":"2023-12-04T14:16:21","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=15753"},"modified":"2023-12-04T22:25:03","modified_gmt":"2023-12-04T14:25:03","slug":"oracle-zhong-shen-me-shi-guang-biao-wei-shen-me-xu","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/04\/oracle-zhong-shen-me-shi-guang-biao-wei-shen-me-xu\/","title":{"rendered":"Oracle \u4e2d\u4ec0\u4e48\u662f\u5149\u6807\uff0c\u4e3a\u4ec0\u4e48\u9700\u8981\u5b83\uff1f"},"content":{"rendered":"<p>\u5728 Oracle \u4e2d\uff0c\u5149\u6807\uff08Cursor\uff09\u662f\u4e00\u79cd\u7528\u4e8e\u5728 PL\/SQL \u4e2d\u5904\u7406\u67e5\u8be2\u7ed3\u679c\u7684\u673a\u5236\u3002\u5149\u6807\u5141\u8bb8\u4f60\u5728\u7a0b\u5e8f\u4e2d\u5904\u7406\u591a\u884c\u67e5\u8be2\u7ed3\u679c\u96c6\uff0c\u800c\u4e0d\u662f\u4e00\u6b21\u53ea\u5904\u7406\u4e00\u884c\u3002\u5149\u6807\u53ef\u4ee5\u770b\u4f5c\u662f\u4e00\u4e2a\u6307\u5411\u67e5\u8be2\u7ed3\u679c\u7684\u6307\u9488\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5149\u6807\u9010\u884c\u68c0\u7d22\u6570\u636e\u3002<\/p>\n<h3>\u4e3a\u4ec0\u4e48\u9700\u8981\u5149\u6807\uff1f<\/h3>\n<ol>\n<li><strong>\u5904\u7406\u591a\u884c\u7ed3\u679c\u96c6\uff1a<\/strong> \u5149\u6807\u4f7f\u5f97\u5728 PL\/SQL \u4e2d\u53ef\u4ee5\u6709\u6548\u5730\u5904\u7406\u591a\u884c\u67e5\u8be2\u7ed3\u679c\u96c6\uff0c\u800c\u4e0d\u9700\u8981\u4e00\u6b21\u6027\u5c06\u6574\u4e2a\u7ed3\u679c\u96c6\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u9010\u884c\u8bbf\u95ee\u6570\u636e\uff1a<\/strong> \u5bf9\u4e8e\u9700\u8981\u9010\u884c\u5904\u7406\u67e5\u8be2\u7ed3\u679c\u7684\u60c5\u51b5\uff0c\u4f7f\u7528\u5149\u6807\u53ef\u4ee5\u6309\u9700\u8bbf\u95ee\u6bcf\u4e00\u884c\u6570\u636e\uff0c\u800c\u4e0d\u5fc5\u4e00\u6b21\u6027\u83b7\u53d6\u6574\u4e2a\u7ed3\u679c\u96c6\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u5b9a\u4f4d\u548c\u66f4\u65b0\u6570\u636e\uff1a<\/strong> \u5149\u6807\u5141\u8bb8\u4f60\u5728\u5faa\u73af\u4e2d\u5b9a\u4f4d\u5230\u7279\u5b9a\u7684\u884c\uff0c\u5e76\u8fdb\u884c\u66f4\u65b0\u6216\u5176\u4ed6\u64cd\u4f5c\uff0c\u5b9e\u73b0\u66f4\u7075\u6d3b\u7684\u6570\u636e\u5904\u7406\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u7528\u4e8e\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\uff1a<\/strong> \u5149\u6807\u901a\u5e38\u7528\u4e8e\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u4e2d\uff0c\u4f7f\u5f97\u8fd9\u4e9b\u6570\u636e\u5e93\u5bf9\u8c61\u80fd\u591f\u6709\u6548\u5730\u5904\u7406\u67e5\u8be2\u7ed3\u679c\u3002<\/p>\n<\/li>\n<\/ol>\n<h3>\u5149\u6807\u7684\u57fa\u672c\u4f7f\u7528\uff1a<\/h3>\n<ol>\n<li>\n<p><strong>\u58f0\u660e\u5149\u6807\uff1a<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 <code>DECLARE<\/code> \u5173\u952e\u5b57\u58f0\u660e\u5149\u6807\uff0c\u5e76\u5b9a\u4e49\u67e5\u8be2\u7684 SELECT \u8bed\u53e5\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-sql  line-numbers\">DECLARE\n cursor_name CURSOR IS\n   SELECT column1, column2\n   FROM your_table\n   WHERE your_condition;\n<\/code><\/pre>\n<\/li>\n<li><strong>\u6253\u5f00\u5149\u6807\uff1a<\/strong>\n<ul>\n<li>\u4f7f\u7528 <code>OPEN<\/code> \u8bed\u53e5\u6253\u5f00\u5149\u6807\uff0c\u4f7f\u5176\u51c6\u5907\u597d\u6267\u884c\u67e5\u8be2\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-sql  line-numbers\">OPEN cursor_name;\n<\/code><\/pre>\n<\/li>\n<li><strong>\u83b7\u53d6\u6570\u636e\uff1a<\/strong>\n<ul>\n<li>\u4f7f\u7528 <code>FETCH INTO<\/code> \u8bed\u53e5\u4ece\u5149\u6807\u4e2d\u83b7\u53d6\u4e00\u884c\u6216\u591a\u884c\u6570\u636e\uff0c\u5e76\u5b58\u50a8\u5728\u53d8\u91cf\u4e2d\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-sql  line-numbers\">FETCH cursor_name INTO variable1, variable2;\n<\/code><\/pre>\n<\/li>\n<li><strong>\u5173\u95ed\u5149\u6807\uff1a<\/strong>\n<ul>\n<li>\u4f7f\u7528 <code>CLOSE<\/code> \u8bed\u53e5\u5173\u95ed\u5149\u6807\uff0c\u91ca\u653e\u8d44\u6e90\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-sql  line-numbers\">CLOSE cursor_name;\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>\u901a\u8fc7\u4f7f\u7528\u5149\u6807\uff0c\u53ef\u4ee5\u66f4\u7075\u6d3b\u5730\u5904\u7406\u67e5\u8be2\u7ed3\u679c\uff0c\u7279\u522b\u662f\u5728\u9700\u8981\u9010\u884c\u5904\u7406\u7ed3\u679c\u96c6\u6216\u5728\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u4e2d\u6267\u884c\u590d\u6742\u7684\u6570\u636e\u64cd\u4f5c\u65f6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Oracle \u4e2d\uff0c\u5149\u6807\uff08Cursor\uff09\u662f\u4e00\u79cd\u7528\u4e8e\u5728 PL\/SQL \u4e2d\u5904\u7406\u67e5\u8be2\u7ed3\u679c\u7684\u673a\u5236\u3002\u5149\u6807\u5141\u8bb8\u4f60\u5728\u7a0b\u5e8f\u4e2d [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[120],"tags":[],"class_list":["post-15753","post","type-post","status-publish","format-standard","hentry","category-oracel"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/15753","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=15753"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/15753\/revisions"}],"predecessor-version":[{"id":15754,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/15753\/revisions\/15754"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=15753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=15753"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=15753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}