{"id":15767,"date":"2023-12-04T22:44:56","date_gmt":"2023-12-04T14:44:56","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=15767"},"modified":"2023-12-04T22:48:59","modified_gmt":"2023-12-04T14:48:59","slug":"oracle-zhong-jie-shi-table-functvion-de-yong-tu","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/04\/oracle-zhong-jie-shi-table-functvion-de-yong-tu\/","title":{"rendered":"Oracle \u4e2d\u89e3\u91ca TABLE Functvion \u7684\u7528\u9014\uff1f"},"content":{"rendered":"<p>\u5728 Oracle \u4e2d\uff0cTABLE \u51fd\u6570\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u51fd\u6570\uff0c\u4e5f\u79f0\u4e3a\u8868\u51fd\u6570\u6216\u591a\u503c\u51fd\u6570\u3002\u5b83\u5141\u8bb8\u4f60\u5c06\u4e00\u4e2a\u590d\u6742\u7684\u67e5\u8be2\u6216\u8ba1\u7b97\u903b\u8f91\u5305\u88c5\u6210\u4e00\u4e2a\u53ef\u5728 SQL \u67e5\u8be2\u4e2d\u8c03\u7528\u7684\u8868\u5f62\u5f0f\u3002TABLE \u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u591a\u4e2a\u884c\u548c\u5217\u7684\u7ed3\u679c\u96c6\uff0c\u8fd9\u4e2a\u7ed3\u679c\u96c6\u53ef\u4ee5\u50cf\u8868\u4e00\u6837\u5728\u67e5\u8be2\u4e2d\u4f7f\u7528\u3002<\/p>\n<h3>TABLE \u51fd\u6570\u7684\u4e3b\u8981\u7528\u9014\uff1a<\/h3>\n<ol>\n<li><strong>\u5c01\u88c5\u590d\u6742\u7684\u8ba1\u7b97\u903b\u8f91\uff1a<\/strong>\n<ul>\n<li>TABLE \u51fd\u6570\u901a\u5e38\u7528\u4e8e\u5c01\u88c5\u590d\u6742\u7684\u8ba1\u7b97\u903b\u8f91\uff0c\u4f7f\u5176\u66f4\u5bb9\u6613\u5728 SQL \u67e5\u8be2\u4e2d\u4f7f\u7528\u3002\u8fd9\u53ef\u4ee5\u5305\u62ec\u6570\u636e\u8f6c\u6362\u3001\u4e1a\u52a1\u89c4\u5219\u8ba1\u7b97\u7b49\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u8fd4\u56de\u8868\u5f62\u5f0f\u7684\u7ed3\u679c\u96c6\uff1a<\/strong>\n<ul>\n<li>TABLE \u51fd\u6570\u8fd4\u56de\u7684\u7ed3\u679c\u96c6\u53ef\u4ee5\u50cf\u8868\u4e00\u6837\u5728\u67e5\u8be2\u4e2d\u4f7f\u7528\uff0c\u53ef\u4ee5\u7528\u4e8e\u8fde\u63a5\u3001\u8fc7\u6ee4\u3001\u805a\u5408\u7b49\u5404\u79cd\u64cd\u4f5c\u3002\u8fd9\u4f7f\u5f97\u53ef\u4ee5\u66f4\u76f4\u89c2\u5730\u5728 SQL \u4e2d\u5904\u7406\u590d\u6742\u7684\u903b\u8f91\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u63d0\u9ad8\u4ee3\u7801\u7684\u6a21\u5757\u5316\u548c\u53ef\u7ef4\u62a4\u6027\uff1a<\/strong>\n<ul>\n<li>\u901a\u8fc7\u4f7f\u7528 TABLE \u51fd\u6570\uff0c\u53ef\u4ee5\u5c06\u590d\u6742\u7684\u903b\u8f91\u6a21\u5757\u5316\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u7ef4\u62a4\u6027\u3002\u8fd9\u4f7f\u5f97\u6570\u636e\u5e93\u4e2d\u7684\u4e1a\u52a1\u903b\u8f91\u66f4\u5bb9\u6613\u7406\u89e3\u548c\u7ef4\u62a4\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>\u793a\u4f8b\uff1a<\/h3>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u6f14\u793a\u4e86\u5982\u4f55\u521b\u5efa\u4e00\u4e2a TABLE \u51fd\u6570\uff1a<\/p>\n<pre><code class=\"language-sql  line-numbers\">CREATE OR REPLACE FUNCTION get_employee_data (dept_id NUMBER)\nRETURN employee_table_type PIPELINED\nAS\nBEGIN\n  FOR emp_rec IN (SELECT employee_id, first_name, last_name FROM employees WHERE department_id = dept_id)\n  LOOP\n    PIPE ROW (emp_rec);\n  END LOOP;\n  RETURN;\nEND;\n\/\n<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>get_employee_data<\/code> \u662f\u4e00\u4e2a TABLE \u51fd\u6570\uff0c\u5b83\u63a5\u53d7\u4e00\u4e2a\u90e8\u95e8 ID \u4f5c\u4e3a\u53c2\u6570\uff0c\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u5458\u5de5\u4fe1\u606f\u7684\u7ed3\u679c\u96c6\u3002\u8fd9\u4e2a\u7ed3\u679c\u96c6\u53ef\u4ee5\u5728\u67e5\u8be2\u4e2d\u4f7f\u7528\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-sql  line-numbers\">SELECT * FROM TABLE(get_employee_data(10));\n<\/code><\/pre>\n<p>\u8fd9\u5c06\u8fd4\u56de\u90e8\u95e8 ID \u4e3a 10 \u7684\u5458\u5de5\u4fe1\u606f\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0cTABLE \u51fd\u6570\u4f7f\u5f97\u590d\u6742\u7684\u903b\u8f91\u80fd\u591f\u4ee5\u8868\u7684\u5f62\u5f0f\u96c6\u6210\u5230 SQL \u67e5\u8be2\u4e2d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Oracle \u4e2d\uff0cTABLE \u51fd\u6570\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u51fd\u6570\uff0c\u4e5f\u79f0\u4e3a\u8868\u51fd\u6570\u6216\u591a\u503c\u51fd\u6570\u3002\u5b83\u5141\u8bb8\u4f60\u5c06\u4e00\u4e2a\u590d\u6742\u7684\u67e5\u8be2\u6216\u8ba1\u7b97 [&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-15767","post","type-post","status-publish","format-standard","hentry","category-oracel"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/15767","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=15767"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/15767\/revisions"}],"predecessor-version":[{"id":15768,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/15767\/revisions\/15768"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=15767"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=15767"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=15767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}