{"id":91950,"date":"2024-10-19T01:32:18","date_gmt":"2024-10-18T17:32:18","guid":{"rendered":"https:\/\/server.hk\/cnblog\/91950\/"},"modified":"2024-10-19T01:32:18","modified_gmt":"2024-10-18T17:32:18","slug":"ora-32481-cycle-%e5%ad%90%e5%8f%a5%e7%9a%84%e5%be%aa%e7%92%b0%e5%80%bc%e5%bf%85%e9%a0%88%e8%88%87%e9%9d%9e%e5%be%aa%e7%92%b0%e5%80%bc%e4%b8%8d%e5%90%8c-oracle-%e5%a0%b1%e9%8c%af-%e6%95%85%e9%9a%9c","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/91950\/","title":{"rendered":"ORA-32481: CYCLE \u5b50\u53e5\u7684\u5faa\u74b0\u503c\u5fc5\u9808\u8207\u975e\u5faa\u74b0\u503c\u4e0d\u540c ORACLE \u5831\u932f \u6545\u969c\u4fee\u5fa9 \u9060\u7a0b\u8655\u7406"},"content":{"rendered":"<h1 id=\"ora-32481-cycle-%e5%ad%90%e5%8f%a5%e7%9a%84%e5%be%aa%e7%92%b0%e5%80%bc%e5%bf%85%e9%a0%88%e8%88%87%e9%9d%9e%e5%be%aa%e7%92%b0%e5%80%bc%e4%b8%8d%e5%90%8c-oracle-%e5%a0%b1%e9%8c%af-%e6%95%85%e9%9a%9c-NoFbYcRaJK\">ORA-32481: CYCLE \u5b50\u53e5\u7684\u5faa\u74b0\u503c\u5fc5\u9808\u8207\u975e\u5faa\u74b0\u503c\u4e0d\u540c 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\u548c\u6578\u64da\u5eab\u7ba1\u7406\u54e1\u53ef\u80fd\u6703\u9047\u5230\u5404\u7a2e\u932f\u8aa4\u4ee3\u78bc\uff0c\u5176\u4e2d\u4e4b\u4e00\u4fbf\u662f <code>ORA-32481<\/code>\u3002\u9019\u500b\u932f\u8aa4\u901a\u5e38\u8207\u4f7f\u7528 CYCLE \u5b50\u53e5\u7684\u905e\u6b78\u67e5\u8a62\u6709\u95dc\uff0c\u7279\u5225\u662f\u5728\u8655\u7406\u5c64\u6b21\u7d50\u69cb\u6578\u64da\u6642\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=\"%e9%8c%af%e8%aa%a4%e5%8e%9f%e5%9b%a0-NoFbYcRaJK\">\u932f\u8aa4\u539f\u56e0<\/h2>\n<p>\u7576\u4f60\u5728 Oracle \u6578\u64da\u5eab\u4e2d\u4f7f\u7528 CYCLE \u5b50\u53e5\u6642\uff0c\u7cfb\u7d71\u6703\u6aa2\u67e5\u5faa\u74b0\u503c\u8207\u975e\u5faa\u74b0\u503c\u4e4b\u9593\u7684\u95dc\u4fc2\u3002\u5982\u679c\u5faa\u74b0\u503c\u8207\u975e\u5faa\u74b0\u503c\u76f8\u540c\uff0c\u5247\u6703\u5f15\u767c <code>ORA-32481<\/code> \u932f\u8aa4\u3002\u9019\u901a\u5e38\u767c\u751f\u5728\u4ee5\u4e0b\u60c5\u6cc1\uff1a<\/p>\n<ul>\n<li>\u5728\u5c64\u6b21\u67e5\u8a62\u4e2d\uff0c\u5faa\u74b0\u503c\u672a\u6b63\u78ba\u8a2d\u7f6e\u3002<\/li>\n<li>\u6578\u64da\u4e2d\u5b58\u5728\u4e0d\u4e00\u81f4\u6027\uff0c\u5c0e\u81f4\u5faa\u74b0\u503c\u8207\u975e\u5faa\u74b0\u503c\u91cd\u8907\u3002<\/li>\n<li>\u67e5\u8a62\u7684\u908f\u8f2f\u932f\u8aa4\uff0c\u672a\u80fd\u6b63\u78ba\u5340\u5206\u5faa\u74b0\u548c\u975e\u5faa\u74b0\u503c\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%a4%ba%e4%be%8b-NoFbYcRaJK\">\u793a\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5728\u67e5\u8a62\u4e2d\u4f7f\u7528 CYCLE \u5b50\u53e5\uff1a<\/p>\n<pre><code>\nSELECT employee_id, manager_id, LEVEL,\n       SYS_CONNECT_BY_PATH(employee_id, '\/') AS path\nFROM employees\nSTART WITH manager_id IS NULL\nCONNECT BY PRIOR employee_id = manager_id\nCYCLE employee_id AS cycle_id\n   SET cycle_id = 'CYCLE'\n   DEFAULT 'NO CYCLE';\n<\/code><\/pre>\n<p>\u5728\u9019\u500b\u67e5\u8a62\u4e2d\uff0c\u5982\u679c <code>employee_id<\/code> \u548c <code>manager_id<\/code> \u4e4b\u9593\u5b58\u5728\u5faa\u74b0\u95dc\u4fc2\uff0c\u5247\u6703\u5f15\u767c <code>ORA-32481<\/code> \u932f\u8aa4\u3002<\/p>\n<h2 id=\"%e6%95%85%e9%9a%9c%e4%bf%ae%e5%be%a9%e6%ad%a5%e9%a9%9f-NoFbYcRaJK\">\u6545\u969c\u4fee\u5fa9\u6b65\u9a5f<\/h2>\n<p>\u8981\u4fee\u5fa9 <code>ORA-32481<\/code> \u932f\u8aa4\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9a5f\u9032\u884c\uff1a<\/p>\n<h3 id=\"1-%e6%aa%a2%e6%9f%a5%e6%95%b8%e6%93%9a%e5%ae%8c%e6%95%b4%e6%80%a7-NoFbYcRaJK\">1. \u6aa2\u67e5\u6578\u64da\u5b8c\u6574\u6027<\/h3>\n<p>\u9996\u5148\uff0c\u6aa2\u67e5\u6578\u64da\u8868\u4e2d\u7684\u6578\u64da\uff0c\u78ba\u4fdd\u6c92\u6709\u91cd\u8907\u7684\u5faa\u74b0\u503c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8a62\u4f86\u6aa2\u67e5\uff1a<\/p>\n<pre><code>\nSELECT employee_id, COUNT(*)\nFROM employees\nGROUP BY employee_id\nHAVING COUNT(*) &gt; 1;\n<\/code><\/pre>\n<h3 id=\"2-%e8%aa%bf%e6%95%b4%e6%9f%a5%e8%a9%a2%e9%82%8f%e8%bc%af-NoFbYcRaJK\">2. \u8abf\u6574\u67e5\u8a62\u908f\u8f2f<\/h3>\n<p>\u5982\u679c\u6578\u64da\u5b8c\u6574\u6027\u6c92\u6709\u554f\u984c\uff0c\u5247\u9700\u8981\u6aa2\u67e5\u67e5\u8a62\u7684\u908f\u8f2f\u3002\u78ba\u4fdd\u5728\u4f7f\u7528 CYCLE \u5b50\u53e5\u6642\uff0c\u5faa\u74b0\u503c\u548c\u975e\u5faa\u74b0\u503c\u4e4b\u9593\u7684\u95dc\u4fc2\u662f\u6b63\u78ba\u7684\u3002<\/p>\n<h3 id=\"3-%e4%bd%bf%e7%94%a8-default-%e5%ad%90%e5%8f%a5-NoFbYcRaJK\">3. \u4f7f\u7528 DEFAULT \u5b50\u53e5<\/h3>\n<p>\u5728 CYCLE \u5b50\u53e5\u4e2d\uff0c\u4f7f\u7528 DEFAULT \u5b50\u53e5\u4f86\u6307\u5b9a\u7576\u767c\u751f\u5faa\u74b0\u6642\u7684\u884c\u70ba\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>\nCYCLE employee_id AS cycle_id\n   SET cycle_id = 'CYCLE'\n   DEFAULT 'NO CYCLE';\n<\/code><\/pre>\n<p>\u9019\u6a23\u53ef\u4ee5\u907f\u514d\u5728\u5faa\u74b0\u767c\u751f\u6642\u5f15\u767c\u932f\u8aa4\u3002<\/p>\n<h2 id=\"%e9%81%a0%e7%a8%8b%e8%99%95%e7%90%86-NoFbYcRaJK\">\u9060\u7a0b\u8655\u7406<\/h2>\n<p>\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\uff0c\u53ef\u80fd\u9700\u8981\u9060\u7a0b\u8655\u7406\u4f86\u89e3\u6c7a <code>ORA-32481<\/code> \u932f\u8aa4\u3002\u9019\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u65b9\u5f0f\u5be6\u73fe\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528\u9060\u7a0b\u684c\u9762\u9023\u63a5\u5230\u6578\u64da\u5eab\u4f3a\u670d\u5668\uff0c\u9032\u884c\u76f4\u63a5\u67e5\u8a62\u548c\u8abf\u8a66\u3002<\/li>\n<li>\u5229\u7528\u6578\u64da\u5eab\u7ba1\u7406\u5de5\u5177\uff08\u5982 SQL Developer\uff09\u9032\u884c\u9060\u7a0b\u67e5\u8a62\u548c\u6578\u64da\u6aa2\u67e5\u3002<\/li>\n<li>\u5982\u679c\u554f\u984c\u6301\u7e8c\u5b58\u5728\uff0c\u8003\u616e\u5c0b\u6c42\u5c08\u696d\u7684\u6578\u64da\u5eab\u7ba1\u7406\u670d\u52d9\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-NoFbYcRaJK\">\u7e3d\u7d50<\/h2>\n<p>\u5728 Oracle \u6578\u64da\u5eab\u4e2d\uff0c<code>ORA-32481<\/code> \u932f\u8aa4\u901a\u5e38\u8207 CYCLE \u5b50\u53e5\u7684\u4f7f\u7528\u6709\u95dc\u3002\u901a\u904e\u6aa2\u67e5\u6578\u64da\u5b8c\u6574\u6027\u3001\u8abf\u6574\u67e5\u8a62\u908f\u8f2f\u4ee5\u53ca\u4f7f\u7528 DEFAULT \u5b50\u53e5\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u6c7a\u6b64\u554f\u984c\u3002\u5982\u679c\u9700\u8981\u9032\u4e00\u6b65\u7684\u652f\u6301\uff0c\u8003\u616e\u4f7f\u7528\u5c08\u696d\u7684\u6578\u64da\u5eab\u7ba1\u7406\u670d\u52d9\u3002\u5c0d\u65bc\u9700\u8981\u9ad8\u6548\u80fd\u548c\u7a69\u5b9a\u6027\u7684\u7528\u6236\uff0c<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u670d\u52d9\u63d0\u4f9b\u4e86\u7406\u60f3\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u5e6b\u52a9\u7528\u6236\u66f4\u597d\u5730\u7ba1\u7406\u548c\u904b\u884c\u5176\u6578\u64da\u5eab\u61c9\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u6c7a ORA-32481 \u932f\u8aa4\uff1a\u5faa\u74b0\u503c\u5fc5\u9808\u8207\u975e\u5faa\u74b0\u503c\u4e0d\u540c\uff0c\u63d0\u4f9b Oracle \u6545\u969c\u4fee\u5fa9\u548c\u9060\u7a0b\u8655\u7406\u6307\u5357\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-91950","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/91950","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=91950"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/91950\/revisions"}],"predecessor-version":[{"id":91951,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/91950\/revisions\/91951"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=91950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=91950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=91950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}