{"id":6110,"date":"2024-11-14T11:34:45","date_gmt":"2024-11-14T03:34:45","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6110\/"},"modified":"2024-11-14T11:34:45","modified_gmt":"2024-11-14T03:34:45","slug":"oracle%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e5%ad%98%e5%82%a8%e8%bf%87%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6110\/","title":{"rendered":"oracle\u5982\u4f55\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b"},"content":{"rendered":"<blockquote><p>\n  \u5b58\u50a8\u8fc7\u7a0b\u662f\u4e00\u7ec4\u53ef\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\u7684 sql \u8bed\u53e5\uff0c\u53ef\u4f5c\u4e3a\u72ec\u7acb\u5355\u5143\u91cd\u590d\u8c03\u7528\u3002\u5b83\u4eec\u53ef\u4ee5\u63a5\u53d7\u53c2\u6570\uff08in\u3001out\u3001inout\uff09\uff0c\u5e76\u63d0\u4f9b\u4ee3\u7801\u91cd\u7528\u3001\u5b89\u5168\u6027\u3001\u6027\u80fd\u548c\u6a21\u5757\u5316\u7684\u4f18\u52bf\u3002\u793a\u4f8b\uff1a\u521b\u5efa\u5b58\u50a8\u8fc7\u7a0b calculate_sum \u6765\u8ba1\u7b97\u4e24\u4e2a\u6570\u5b57\u7684\u603b\u548c\u5e76\u5c06\u5176\u5b58\u50a8\u5728 out \u53c2\u6570\u4e2d\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/12\/2024061223482438533.jpg\" class=\"aligncenter\" title=\"oracle\u5982\u4f55\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\u63d2\u56fe\" alt=\"oracle\u5982\u4f55\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 Oracle \u5b58\u50a8\u8fc7\u7a0b<\/strong><\/p>\n<p><strong>\u4e00\u3001\u4ec0\u4e48\u662f\u5b58\u50a8\u8fc7\u7a0b\uff1f<\/strong><\/p>\n<p>\u5b58\u50a8\u8fc7\u7a0b\u662f\u4e00\u7ec4\u53ef\u4ee5\u5728\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u3001\u7f16\u8bd1\u548c\u5b58\u50a8\u7684 SQL \u8bed\u53e5\u3002\u4e0e\u5355\u72ec\u6267\u884c\u7684 SQL \u8bed\u53e5\u4e0d\u540c\uff0c\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4f5c\u4e3a\u72ec\u7acb\u7684\u5355\u5143\u91cd\u590d\u8c03\u7528\u3002<\/p>\n<p><strong>\u4e8c\u3001\u521b\u5efa\u5b58\u50a8\u8fc7\u7a0b<\/strong><\/p>\n<p>\u8981\u521b\u5efa\u5b58\u50a8\u8fc7\u7a0b\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a<\/p>\n<pre>CREATE PROCEDURE procedure_name (parameter_list)\nAS\nBEGIN\n  -- \u5b58\u50a8\u8fc7\u7a0b\u7684\u4e3b\u4f53\n  SQL \u8bed\u53e5\nEND;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4e09\u3001\u53c2\u6570<\/strong><\/p>\n<p>\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u63a5\u53d7\u53c2\u6570\uff0c\u8fd9\u4e9b\u53c2\u6570\u5141\u8bb8\u5728\u8c03\u7528\u65f6\u4f20\u9012\u503c\u3002\u53c2\u6570\u7c7b\u578b\u53ef\u4ee5\u662f IN\uff08\u8f93\u5165\uff09\u3001OUT\uff08\u8f93\u51fa\uff09\u6216 INOUT\uff08\u8f93\u5165\u548c\u8f93\u51fa\uff09\u3002<\/p>\n<p><strong>\u56db\u3001\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b<\/strong><\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\uff1a<\/p>\n<pre>CALL procedure_name (parameter_value1, parameter_value2, ...);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4e94\u3001\u4f18\u70b9<\/strong><\/p>\n<p>\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\u6709\u5f88\u591a\u4f18\u70b9\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li> <strong>\u4ee3\u7801\u91cd\u7528\uff1a<\/strong>\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u51cf\u5c11\u4ee3\u7801\u91cd\u590d\uff0c\u56e0\u4e3a\u76f8\u540c\u7684\u903b\u8f91\u53ef\u4ee5\u5728\u591a\u4e2a\u5730\u65b9\u8c03\u7528\u3002<\/li>\n<li> <strong>\u5b89\u5168\u6027\uff1a<\/strong>\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u4fdd\u62a4\u514d\u53d7\u672a\u7ecf\u6388\u6743\u7684\u8bbf\u95ee\u3002<\/li>\n<li> <strong>\u6027\u80fd\uff1a<\/strong>\u7f16\u8bd1\u540e\u7684\u5b58\u50a8\u8fc7\u7a0b\u901a\u5e38\u6bd4\u672a\u7f16\u8bd1\u7684 SQL \u8bed\u53e5\u6267\u884c\u5f97\u66f4\u5feb\u3002<\/li>\n<li> <strong>\u6a21\u5757\u5316\uff1a<\/strong>\u5b58\u50a8\u8fc7\u7a0b\u5c06\u590d\u6742\u7684\u4ee3\u7801\u7ec4\u7ec7\u6210\u53ef\u7ba1\u7406\u7684\u5355\u5143\u3002<\/li>\n<\/ul>\n<p><strong>\u516d\u3001\u793a\u4f8b<\/strong><\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u5b58\u50a8\u8fc7\u7a0b\u6765\u8ba1\u7b97\u4e24\u4e2a\u6570\u5b57\u7684\u603b\u548c\uff1a<\/p>\n<pre>CREATE PROCEDURE calculate_sum (\n  IN num1 NUMBER,\n  IN num2 NUMBER,\n  OUT result NUMBER\n)\nAS\nBEGIN\n  result := num1 + num2;\nEND;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8c03\u7528\u6b64\u5b58\u50a8\u8fc7\u7a0b\uff1a<\/p>\n<pre>CALL calculate_sum (5, 10, @result);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>@result \u8f93\u51fa\u53c2\u6570\u5c06\u5b58\u50a8\u8ba1\u7b97\u51fa\u7684\u603b\u548c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b58\u50a8\u8fc7\u7a0b\u662f\u4e00\u7ec4\u53ef\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\u7684 sql \u8bed\u53e5\uff0c\u53ef\u4f5c\u4e3a\u72ec\u7acb\u5355\u5143\u91cd\u590d\u8c03\u7528\u3002\u5b83\u4eec\u53ef\u4ee5\u63a5\u53d7\u53c2\u6570\uff08in\u3001out\u3001inout\uff09\uff0c\u5e76\u63d0\u4f9b\u4ee3\u7801\u91cd\u7528\u3001\u5b89\u5168\u6027\u3001\u6027\u80fd\u548c\u6a21\u5757\u5316\u7684\u4f18\u52bf\u3002\u793a\u4f8b\uff1a\u521b\u5efa\u5b58\u50a8\u8fc7\u7a0b calculate_sum \u6765\u8ba1\u7b97\u4e24\u4e2a\u6570\u5b57\u7684\u603b\u548c\u5e76\u5c06\u5176\u5b58\u50a8\u5728 out \u53c2\u6570\u4e2d\u3002 \u5982\u4f55\u4f7f\u7528 Oracle \u5b58\u50a8\u8fc7\u7a0b \u4e00\u3001\u4ec0\u4e48\u662f\u5b58\u50a8\u8fc7\u7a0b\uff1f \u5b58\u50a8\u8fc7\u7a0b\u662f\u4e00\u7ec4\u53ef\u4ee5\u5728\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u3001\u7f16\u8bd1\u548c\u5b58\u50a8\u7684 SQL \u8bed\u53e5\u3002\u4e0e\u5355\u72ec\u6267\u884c\u7684 SQL \u8bed\u53e5\u4e0d\u540c\uff0c\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4f5c\u4e3a\u72ec\u7acb\u7684\u5355\u5143\u91cd\u590d\u8c03\u7528\u3002 \u4e8c\u3001\u521b\u5efa\u5b58\u50a8\u8fc7\u7a0b \u8981\u521b\u5efa\u5b58\u50a8\u8fc7\u7a0b\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a CREATE PROCEDURE procedure_name (parameter_list) AS BEGIN &#8212; \u5b58\u50a8\u8fc7\u7a0b\u7684\u4e3b\u4f53 SQL \u8bed\u53e5 END; \u767b\u5f55\u540e\u590d\u5236 \u4e09\u3001\u53c2\u6570 \u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u63a5\u53d7\u53c2\u6570\uff0c\u8fd9\u4e9b\u53c2\u6570\u5141\u8bb8\u5728\u8c03\u7528\u65f6\u4f20\u9012\u503c\u3002\u53c2\u6570\u7c7b\u578b\u53ef\u4ee5\u662f IN\uff08\u8f93\u5165\uff09\u3001OUT\uff08\u8f93\u51fa\uff09\u6216 INOUT\uff08\u8f93\u5165\u548c\u8f93\u51fa\uff09\u3002 \u56db\u3001\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b \u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\uff1a CALL procedure_name (parameter_value1, parameter_value2, &#8230;); \u767b\u5f55\u540e\u590d\u5236 \u4e94\u3001\u4f18\u70b9 \u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\u6709\u5f88\u591a\u4f18\u70b9\uff0c\u5305\u62ec\uff1a \u4ee3\u7801\u91cd\u7528\uff1a\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u51cf\u5c11\u4ee3\u7801\u91cd\u590d\uff0c\u56e0\u4e3a\u76f8\u540c\u7684\u903b\u8f91\u53ef\u4ee5\u5728\u591a\u4e2a\u5730\u65b9\u8c03\u7528\u3002 \u5b89\u5168\u6027\uff1a\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u4fdd\u62a4\u514d\u53d7\u672a\u7ecf\u6388\u6743\u7684\u8bbf\u95ee\u3002 \u6027\u80fd\uff1a\u7f16\u8bd1\u540e\u7684\u5b58\u50a8\u8fc7\u7a0b\u901a\u5e38\u6bd4\u672a\u7f16\u8bd1\u7684 SQL \u8bed\u53e5\u6267\u884c\u5f97\u66f4\u5feb\u3002 \u6a21\u5757\u5316\uff1a\u5b58\u50a8\u8fc7\u7a0b\u5c06\u590d\u6742\u7684\u4ee3\u7801\u7ec4\u7ec7\u6210\u53ef\u7ba1\u7406\u7684\u5355\u5143\u3002 \u516d\u3001\u793a\u4f8b \u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u5b58\u50a8\u8fc7\u7a0b\u6765\u8ba1\u7b97\u4e24\u4e2a\u6570\u5b57\u7684\u603b\u548c\uff1a CREATE PROCEDURE calculate_sum [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6110","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=6110"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6110\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}