{"id":91958,"date":"2024-10-19T01:36:20","date_gmt":"2024-10-18T17:36:20","guid":{"rendered":"https:\/\/server.hk\/cnblog\/91958\/"},"modified":"2024-10-19T01:36:20","modified_gmt":"2024-10-18T17:36:20","slug":"ora-32487-%e5%9c%a8%e9%81%9e%e6%ad%b8-with-%e6%9f%a5%e8%a9%a2%e4%b8%ad%e4%b8%8d%e6%94%af%e6%8c%81%e8%81%af%e6%8e%a5-oracle-%e5%a0%b1%e9%8c%af-%e6%95%85%e9%9a%9c%e4%bf%ae%e5%be%a9-%e9%81%a0%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/91958\/","title":{"rendered":"ORA-32487: \u5728\u905e\u6b78 WITH \u67e5\u8a62\u4e2d\u4e0d\u652f\u6301\u806f\u63a5 ORACLE \u5831\u932f \u6545\u969c\u4fee\u5fa9 \u9060\u7a0b\u8655\u7406"},"content":{"rendered":"<h1 id=\"ora-32487-%e5%9c%a8%e9%81%9e%e6%ad%b8-with-%e6%9f%a5%e8%a9%a2%e4%b8%ad%e4%b8%8d%e6%94%af%e6%8c%81%e8%81%af%e6%8e%a5-oracle-%e5%a0%b1%e9%8c%af-%e6%95%85%e9%9a%9c%e4%bf%ae%e5%be%a9-%e9%81%a0%e7%a8%8b-RXcdZFaLUS\">ORA-32487: \u5728\u905e\u6b78 WITH \u67e5\u8a62\u4e2d\u4e0d\u652f\u6301\u806f\u63a5 ORACLE \u5831\u932f \u6545\u969c\u4fee\u5fa9 \u9060\u7a0b\u8655\u7406<\/h1>\n<p>\u5728\u4f7f\u7528 Oracle \u6578\u64da\u5eab\u6642\uff0c\u958b\u767c\u8005\u53ef\u80fd\u6703\u9047\u5230\u5404\u7a2e\u932f\u8aa4\uff0c\u5176\u4e2d\u4e4b\u4e00\u5c31\u662f <code>ORA-32487<\/code> \u932f\u8aa4\u3002\u9019\u500b\u932f\u8aa4\u901a\u5e38\u51fa\u73fe\u5728\u4f7f\u7528\u905e\u6b78 <code>WITH<\/code> \u67e5\u8a62\u6642\uff0c\u4e26\u4e14\u5617\u8a66\u5728\u67e5\u8a62\u4e2d\u9032\u884c\u806f\u63a5\u64cd\u4f5c\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e\u9019\u500b\u932f\u8aa4\u7684\u539f\u56e0\u3001\u5f71\u97ff\u4ee5\u53ca\u5982\u4f55\u9032\u884c\u6545\u969c\u4fee\u5fa9\u3002<\/p>\n<h2 id=\"ora-32487-%e9%8c%af%e8%aa%a4%e7%9a%84%e5%8e%9f%e5%9b%a0-RXcdZFaLUS\">ORA-32487 \u932f\u8aa4\u7684\u539f\u56e0<\/h2>\n<p>\u7576\u4f60\u5728 Oracle \u6578\u64da\u5eab\u4e2d\u4f7f\u7528\u905e\u6b78 <code>WITH<\/code> \u67e5\u8a62\u6642\uff0c\u8a72\u67e5\u8a62\u7684\u7d50\u69cb\u5fc5\u9808\u9075\u5faa\u7279\u5b9a\u7684\u898f\u5247\u3002\u6839\u64da Oracle \u7684\u6587\u6a94\uff0c\u905e\u6b78\u67e5\u8a62\u7684\u4e3b\u8981\u76ee\u7684\u662f\u5f9e\u4e00\u500b\u57fa\u790e\u96c6\u958b\u59cb\uff0c\u7136\u5f8c\u901a\u904e\u4e0d\u65b7\u5730\u61c9\u7528\u67d0\u4e9b\u64cd\u4f5c\u4f86\u751f\u6210\u4e00\u500b\u7d50\u679c\u96c6\u3002\u7136\u800c\uff0c\u9019\u4e9b\u67e5\u8a62\u4e0d\u652f\u6301\u5728\u905e\u6b78\u90e8\u5206\u4e2d\u9032\u884c\u806f\u63a5\u64cd\u4f5c\u3002<\/p>\n<p>\u5177\u9ad4\u4f86\u8aaa\uff0c<code>ORA-32487<\/code> \u932f\u8aa4\u901a\u5e38\u51fa\u73fe\u5728\u4ee5\u4e0b\u60c5\u6cc1\uff1a<\/p>\n<ul>\n<li>\u5728\u905e\u6b78\u67e5\u8a62\u7684 <code>UNION ALL<\/code> \u90e8\u5206\u4e2d\u5617\u8a66\u9032\u884c\u806f\u63a5\u3002<\/li>\n<li>\u4f7f\u7528\u4e86\u4e0d\u652f\u6301\u7684 SQL \u8a9e\u6cd5\u6216\u7d50\u69cb\u3002<\/li>\n<li>\u67e5\u8a62\u7684\u908f\u8f2f\u8a2d\u8a08\u4e0d\u7b26\u5408 Oracle \u7684\u8981\u6c42\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e4%bf%ae%e5%be%a9-ora-32487-%e9%8c%af%e8%aa%a4-RXcdZFaLUS\">\u5982\u4f55\u4fee\u5fa9 ORA-32487 \u932f\u8aa4<\/h2>\n<p>\u4fee\u5fa9 <code>ORA-32487<\/code> \u932f\u8aa4\u7684\u7b2c\u4e00\u6b65\u662f\u6aa2\u67e5\u4f60\u7684 SQL \u67e5\u8a62\u7d50\u69cb\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u898b\u7684\u4fee\u5fa9\u65b9\u6cd5\uff1a<\/p>\n<h3 id=\"1-%e7%a2%ba%e4%bf%9d%e9%81%9e%e6%ad%b8%e6%9f%a5%e8%a9%a2%e7%9a%84%e6%ad%a3%e7%a2%ba%e6%80%a7-RXcdZFaLUS\">1. \u78ba\u4fdd\u905e\u6b78\u67e5\u8a62\u7684\u6b63\u78ba\u6027<\/h3>\n<p>\u6aa2\u67e5\u4f60\u7684\u905e\u6b78\u67e5\u8a62\uff0c\u78ba\u4fdd\u5728\u905e\u6b78\u90e8\u5206\u4e2d\u6c92\u6709\u4f7f\u7528\u806f\u63a5\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u905e\u6b78\u67e5\u8a62\u793a\u4f8b\uff1a<\/p>\n<pre><code>\nWITH RECURSIVE employee_hierarchy AS (\n    SELECT employee_id, manager_id, employee_name\n    FROM employees\n    WHERE manager_id IS NULL\n    UNION ALL\n    SELECT e.employee_id, e.manager_id, e.employee_name\n    FROM employees e\n    INNER JOIN employee_hierarchy eh ON e.manager_id = eh.employee_id\n)\nSELECT * FROM employee_hierarchy;\n<\/code><\/pre>\n<p>\u5728\u9019\u500b\u4f8b\u5b50\u4e2d\uff0c<code>INNER JOIN<\/code> \u662f\u5728\u905e\u6b78\u90e8\u5206\u4e2d\u4f7f\u7528\u7684\uff0c\u9019\u6703\u5c0e\u81f4 <code>ORA-32487<\/code> \u932f\u8aa4\u3002\u8981\u4fee\u5fa9\u9019\u500b\u554f\u984c\uff0c\u53ef\u4ee5\u5c07\u806f\u63a5\u79fb\u5230\u5916\u90e8\u67e5\u8a62\u4e2d\u3002<\/p>\n<h3 id=\"2-%e4%bd%bf%e7%94%a8%e8%87%a8%e6%99%82%e8%a1%a8%e6%88%96%e5%ad%90%e6%9f%a5%e8%a9%a2-RXcdZFaLUS\">2. \u4f7f\u7528\u81e8\u6642\u8868\u6216\u5b50\u67e5\u8a62<\/h3>\n<p>\u5982\u679c\u9700\u8981\u5728\u67e5\u8a62\u4e2d\u4f7f\u7528\u806f\u63a5\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528\u81e8\u6642\u8868\u6216\u5b50\u67e5\u8a62\u4f86\u5148\u7372\u53d6\u6240\u9700\u7684\u6578\u64da\uff0c\u7136\u5f8c\u518d\u9032\u884c\u806f\u63a5\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>\nWITH employee_data AS (\n    SELECT employee_id, employee_name\n    FROM employees\n)\nSELECT ed.employee_id, ed.employee_name, m.employee_name AS manager_name\nFROM employee_data ed\nLEFT JOIN employees m ON ed.manager_id = m.employee_id;\n<\/code><\/pre>\n<h3 id=\"3-%e6%b8%ac%e8%a9%a6%e5%92%8c%e9%a9%97%e8%ad%89-RXcdZFaLUS\">3. \u6e2c\u8a66\u548c\u9a57\u8b49<\/h3>\n<p>\u5728\u9032\u884c\u4fee\u6539\u5f8c\uff0c\u52d9\u5fc5\u6e2c\u8a66\u67e5\u8a62\u4ee5\u78ba\u4fdd\u5176\u6b63\u78ba\u6027\u548c\u6027\u80fd\u3002\u4f7f\u7528 <code>EXPLAIN PLAN<\/code> \u4f86\u5206\u6790\u67e5\u8a62\u7684\u57f7\u884c\u8a08\u5283\uff0c\u78ba\u4fdd\u6c92\u6709\u6027\u80fd\u74f6\u9838\u3002<\/p>\n<h2 id=\"%e7%b5%90%e8%ab%96-RXcdZFaLUS\">\u7d50\u8ad6<\/h2>\n<p>\u5728 Oracle \u6578\u64da\u5eab\u4e2d\uff0c<code>ORA-32487<\/code> \u932f\u8aa4\u662f\u7531\u65bc\u5728\u905e\u6b78 <code>WITH<\/code> \u67e5\u8a62\u4e2d\u4e0d\u652f\u6301\u806f\u63a5\u6240\u5f15\u8d77\u7684\u3002\u901a\u904e\u6aa2\u67e5\u67e5\u8a62\u7d50\u69cb\u3001\u4f7f\u7528\u81e8\u6642\u8868\u6216\u5b50\u67e5\u8a62\u4f86\u907f\u514d\u5728\u905e\u6b78\u90e8\u5206\u4e2d\u4f7f\u7528\u806f\u63a5\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u4fee\u5fa9\u6b64\u932f\u8aa4\u3002\u4e86\u89e3\u9019\u4e9b\u57fa\u672c\u539f\u5247\u5c07\u6709\u52a9\u65bc\u958b\u767c\u8005\u5728\u4f7f\u7528 Oracle \u6578\u64da\u5eab\u6642\u66f4\u6709\u6548\u5730\u9032\u884c\u6545\u969c\u6392\u9664\u3002<\/p>\n<p>\u5982\u9700\u9032\u4e00\u6b65\u4e86\u89e3\u6709\u95dc <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u548c\u5176\u4ed6\u6578\u64da\u5eab\u89e3\u6c7a\u65b9\u6848\u7684\u4fe1\u606f\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u6c7a ORA-32487 \u932f\u8aa4\uff1a\u5728\u905e\u6b78 WITH \u67e5\u8a62\u4e2d\u4e0d\u652f\u6301\u806f\u63a5\u7684\u6545\u969c\u4fee\u5fa9\u8207\u9060\u7a0b\u8655\u7406\u6307\u5357\uff0c\u52a9\u60a8\u5feb\u901f\u6392\u9664\u554f\u984c\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-91958","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/91958","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=91958"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/91958\/revisions"}],"predecessor-version":[{"id":91959,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/91958\/revisions\/91959"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=91958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=91958"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=91958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}