{"id":15845,"date":"2023-12-04T23:29:30","date_gmt":"2023-12-04T15:29:30","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=15845"},"modified":"2023-12-04T23:31:27","modified_gmt":"2023-12-04T15:31:27","slug":"oracle-zhong-cun-chu-guo-cheng-you-biao-he-han-shu","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/04\/oracle-zhong-cun-chu-guo-cheng-you-biao-he-han-shu\/","title":{"rendered":"Oracle \u4e2d\u5b58\u50a8\u8fc7\u7a0b\uff0c\u6e38\u6807\u548c\u51fd\u6570\u7684\u533a\u522b\uff1f"},"content":{"rendered":"<p>\u5728 Oracle \u6570\u636e\u5e93\u4e2d\uff0c\u5b58\u50a8\u8fc7\u7a0b\u3001\u6e38\u6807\u548c\u51fd\u6570\u662f\u4e09\u4e2a\u4e0d\u540c\u7684\u6570\u636e\u5e93\u5bf9\u8c61\uff0c\u5b83\u4eec\u5728\u5b9a\u4e49\u548c\u7528\u9014\u4e0a\u6709\u4e00\u4e9b\u533a\u522b\u3002\u4ee5\u4e0b\u662f\u5b83\u4eec\u7684\u4e3b\u8981\u533a\u522b\uff1a<\/p>\n<h3>\u5b58\u50a8\u8fc7\u7a0b\uff08Stored Procedure\uff09\uff1a<\/h3>\n<ol>\n<li><strong>\u5b9a\u4e49\uff1a<\/strong>\n<ul>\n<li>\u5b58\u50a8\u8fc7\u7a0b\u662f\u4e00\u7ec4SQL\u8bed\u53e5\u548cPL\/SQL\u4ee3\u7801\u7684\u96c6\u5408\uff0c\u53ef\u4ee5\u88ab\u547d\u540d\u5e76\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u4ee5\u4fbf\u5728\u9700\u8981\u65f6\u88ab\u8c03\u7528\u6267\u884c\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u8fd4\u56de\u7c7b\u578b\uff1a<\/strong>\n<ul>\n<li>\u5b58\u50a8\u8fc7\u7a0b\u901a\u5e38\u4e0d\u8fd4\u56de\u503c\u6216\u8fd4\u56de\u591a\u4e2a\u8f93\u51fa\u53c2\u6570\uff0c\u5176\u4e3b\u8981\u76ee\u7684\u662f\u6267\u884c\u4e00\u4e2a\u8fc7\u7a0b\u6027\u4efb\u52a1\uff0c\u800c\u4e0d\u662f\u4ea7\u751f\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u7528\u9014\uff1a<\/strong>\n<ul>\n<li>\u901a\u5e38\u7528\u4e8e\u6267\u884c\u4e00\u7cfb\u5217\u7684\u6570\u636e\u5e93\u64cd\u4f5c\uff0c\u4f8b\u5982\u63d2\u5165\u3001\u66f4\u65b0\u3001\u5220\u9664\u7b49\uff0c\u4ee5\u53ca\u6267\u884c\u4e1a\u52a1\u903b\u8f91\u3002\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u5305\u542b\u4e8b\u52a1\u63a7\u5236\u548c\u9519\u8bef\u5904\u7406\u903b\u8f91\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u8c03\u7528\u65b9\u5f0f\uff1a<\/strong>\n<ul>\n<li>\u53ef\u4ee5\u901a\u8fc7 <code>EXECUTE<\/code> \u6216 <code>CALL<\/code> \u8bed\u53e5\u76f4\u63a5\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-sql  line-numbers\">EXECUTE your_stored_procedure;\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<h3>\u6e38\u6807\uff08Cursor\uff09\uff1a<\/h3>\n<ol>\n<li><strong>\u5b9a\u4e49\uff1a<\/strong>\n<ul>\n<li>\u6e38\u6807\u662f\u4e00\u79cd\u7528\u4e8e\u5728 PL\/SQL \u4e2d\u5904\u7406\u67e5\u8be2\u7ed3\u679c\u96c6\u7684\u6570\u636e\u7ed3\u6784\u3002\u53ef\u4ee5\u4f7f\u7528\u663e\u5f0f\u6e38\u6807\u6216\u9690\u5f0f\u6e38\u6807\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u8fd4\u56de\u7c7b\u578b\uff1a<\/strong>\n<ul>\n<li>\u6e38\u6807\u8fd4\u56de\u4e00\u7ec4\u7ed3\u679c\u96c6\uff0c\u901a\u5e38\u7528\u4e8e\u8fed\u4ee3\u904d\u5386\u67e5\u8be2\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u7528\u9014\uff1a<\/strong>\n<ul>\n<li>\u4e3b\u8981\u7528\u4e8e\u5728 PL\/SQL \u7a0b\u5e8f\u4e2d\u5904\u7406 SELECT \u8bed\u53e5\u7684\u7ed3\u679c\uff0c\u5141\u8bb8\u9010\u884c\u5904\u7406\u6570\u636e\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u8c03\u7528\u65b9\u5f0f\uff1a<\/strong>\n<ul>\n<li>\u6e38\u6807\u901a\u5e38\u7531 PL\/SQL \u8bed\u53e5\u4f7f\u7528\uff0c\u53ef\u4ee5\u5728 BEGIN&#8230;END \u5757\u4e2d\u5b9a\u4e49\u548c\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-plsql  line-numbers\">DECLARE\n  CURSOR your_cursor IS SELECT * FROM your_table;\nBEGIN\n  FOR row IN your_cursor LOOP\n     -- \u5904\u7406\u6bcf\u4e00\u884c\u6570\u636e\n  END LOOP;\nEND;\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<h3>\u51fd\u6570\uff08Function\uff09\uff1a<\/h3>\n<ol>\n<li><strong>\u5b9a\u4e49\uff1a<\/strong>\n<ul>\n<li>\u51fd\u6570\u662f\u4e00\u6bb5\u53ef\u91cd\u7528\u7684PL\/SQL\u4ee3\u7801\uff0c\u53ef\u4ee5\u63a5\u6536\u53c2\u6570\u5e76\u8fd4\u56de\u4e00\u4e2a\u503c\u3002\u51fd\u6570\u53ef\u4ee5\u5d4c\u5957\u5728 SQL \u8bed\u53e5\u4e2d\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u8fd4\u56de\u7c7b\u578b\uff1a<\/strong>\n<ul>\n<li>\u51fd\u6570\u5fc5\u987b\u8fd4\u56de\u4e00\u4e2a\u503c\uff0c\u53ef\u4ee5\u662f\u6807\u91cf\u503c\u3001\u6e38\u6807\u3001\u6216\u8bb0\u5f55\u7c7b\u578b\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u7528\u9014\uff1a<\/strong>\n<ul>\n<li>\u901a\u5e38\u7528\u4e8e\u8ba1\u7b97\u548c\u8fd4\u56de\u4e00\u4e2a\u5355\u4e00\u7684\u503c\uff0c\u4f8b\u5982\u6267\u884c\u4e00\u4e9b\u8ba1\u7b97\u3001\u6570\u636e\u8f6c\u6362\u6216\u68c0\u7d22\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u8c03\u7528\u65b9\u5f0f\uff1a<\/strong>\n<ul>\n<li>\u53ef\u4ee5\u5728 SQL \u8bed\u53e5\u4e2d\u76f4\u63a5\u8c03\u7528\u5b58\u50a8\u51fd\u6570\uff0c\u4e5f\u53ef\u4ee5\u5728 PL\/SQL \u5757\u4e2d\u8c03\u7528\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-sql  line-numbers\">SELECT your_stored_function(parameters) FROM dual;\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>\u603b\u4f53\u800c\u8a00\uff0c\u5b58\u50a8\u8fc7\u7a0b\u7528\u4e8e\u6267\u884c\u4e00\u7cfb\u5217\u7684\u6570\u636e\u5e93\u64cd\u4f5c\uff0c\u6e38\u6807\u7528\u4e8e\u5904\u7406\u67e5\u8be2\u7ed3\u679c\u96c6\uff0c\u800c\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u5e76\u8fd4\u56de\u4e00\u4e2a\u503c\u3002\u9009\u62e9\u4f7f\u7528\u54ea\u79cd\u5bf9\u8c61\u53d6\u51b3\u4e8e\u5177\u4f53\u7684\u9700\u6c42\u548c\u6570\u636e\u7684\u7ed3\u6784\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Oracle \u6570\u636e\u5e93\u4e2d\uff0c\u5b58\u50a8\u8fc7\u7a0b\u3001\u6e38\u6807\u548c\u51fd\u6570\u662f\u4e09\u4e2a\u4e0d\u540c\u7684\u6570\u636e\u5e93\u5bf9\u8c61\uff0c\u5b83\u4eec\u5728\u5b9a\u4e49\u548c\u7528\u9014\u4e0a\u6709\u4e00\u4e9b\u533a\u522b\u3002\u4ee5\u4e0b\u662f\u5b83 [&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-15845","post","type-post","status-publish","format-standard","hentry","category-oracel"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/15845","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=15845"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/15845\/revisions"}],"predecessor-version":[{"id":15846,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/15845\/revisions\/15846"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=15845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=15845"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=15845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}