
{"id":343,"date":"2021-08-31T20:29:47","date_gmt":"2021-08-31T12:29:47","guid":{"rendered":"http:\/\/dba.qishuo.xin\/?p=343"},"modified":"2022-06-20T08:59:33","modified_gmt":"2022-06-20T00:59:33","slug":"oracle%e4%b9%8bwith-as%e5%92%8cupdate%e7%94%a8%e6%b3%95","status":"publish","type":"post","link":"http:\/\/dba.qishuo.xin\/?p=343","title":{"rendered":"Oracle\u4e4bwith as\u548cupdate\u7528\u6cd5"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<label for=\"ez-toc-cssicon-toggle-item-6a143b9c56d32\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a143b9c56d32\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/dba.qishuo.xin\/?p=343\/#1_%E6%9B%B4%E6%96%B0%E6%9C%AC%E7%BA%A7%E9%83%A8%E9%97%A8%E5%90%8D%E7%A7%B0%E5%85%A8%E8%B7%AF%E5%BE%84\" >1. \u66f4\u65b0\u672c\u7ea7\u90e8\u95e8\u540d\u79f0\u5168\u8def\u5f84<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/dba.qishuo.xin\/?p=343\/#2_%E6%9B%B4%E6%96%B0%E4%B8%8A%E7%BA%A7%E9%83%A8%E9%97%A8%E7%BC%96%E5%8F%B7%E5%85%A8%E8%B7%AF%E5%BE%84\" >2.  \u66f4\u65b0\u4e0a\u7ea7\u90e8\u95e8\u7f16\u53f7\u5168\u8def\u5f84<\/a><\/li><\/ul><\/nav><\/div>\n<h4><span class=\"ez-toc-section\" id=\"1_%E6%9B%B4%E6%96%B0%E6%9C%AC%E7%BA%A7%E9%83%A8%E9%97%A8%E5%90%8D%E7%A7%B0%E5%85%A8%E8%B7%AF%E5%BE%84\"><\/span>1. \u66f4\u65b0\u672c\u7ea7\u90e8\u95e8\u540d\u79f0\u5168\u8def\u5f84<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-sql\">BEGIN\n  FOR se IN (SELECT epid FROM sc_enterprice WHERE epid &gt; 0) LOOP\n    UPDATE sc_accdep x\n       SET x.namepath =(WITH depinfo\n                         AS (SELECT a.epid,\n                                    a.accdepid,\n                                    sys_connect_by_path(a.accdepname,&#039;\/&#039;) AS depNamePath\n                               FROM (SELECT * FROM sc_accdep WHERE epid = se.epid) a\n                              START WITH a.parentid = -1\n                            CONNECT BY PRIOR a.accdepid = a.parentid)\n                     SELECT y.depNamePath\n                       FROM depinfo y\n                      WHERE x.epid = y.epid\n                        AND x.accdepid = y.accdepid)\n     WHERE x.epid = se.epid;\n  END LOOP;\n\n  COMMIT;\n\nEXCEPTION\n WHEN OTHERS THEN\n    ROLLBACK;\n    RAISE_APPLICATION_ERROR(&#039;-20002&#039;,&#039;\u811a\u672c\u6267\u884c\u5f02\u5e38\uff1a&#039; || SQLERRM);\nEND;<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"2_%E6%9B%B4%E6%96%B0%E4%B8%8A%E7%BA%A7%E9%83%A8%E9%97%A8%E7%BC%96%E5%8F%B7%E5%85%A8%E8%B7%AF%E5%BE%84\"><\/span>2.  \u66f4\u65b0\u4e0a\u7ea7\u90e8\u95e8\u7f16\u53f7\u5168\u8def\u5f84<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-sql\"> UPDATE sc_accdep x\n    SET x.idpath =(WITH depinfo\n                       AS (SELECT a.epid,\n                                  a.accdepid,\n                                  sys_connect_by_path(a.accdepid,&#039;\/&#039;) AS idpath\n                             FROM (SELECT * FROM sc_accdep WHERE epid = 1) a\n                            START WITH a.parentid = -1\n                          CONNECT BY PRIOR a.accdepid = a.parentid)\n                   SELECT SUBSTR(y.idpath,1,instr(y.idpath,&#039;\/&#039;,-1)) as idpath\n                     FROM depinfo y\n                    WHERE x.epid = y.epid\n                      AND x.accdepid = y.accdepid)\n  WHERE x.epid = 1;\n\nCOMMIT;<\/code><\/pre>\n<ul>\n<li>\u9644\uff1a<br \/>\nMariaDB\u4e4bwith as\u548cupdate\u7528\u6cd5\uff1a<a target=\"_blank\" href=\"http:\/\/dba.qishuo.xin\/?p=1711\">http:\/\/dba.qishuo.xin\/?p=1711<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>1. \u66f4\u65b0\u672c\u7ea7\u90e8\u95e8\u540d\u79f0\u5168\u8def\u5f84 BEGIN FOR &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,2],"tags":[16,42,41,40],"class_list":["post-343","post","type-post","status-publish","format-standard","hentry","category-oracle-sqlplsql","category-oracle","tag-oracle","tag-sql","tag-update","tag-with-as"],"_links":{"self":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=343"}],"version-history":[{"count":10,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/343\/revisions"}],"predecessor-version":[{"id":1820,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/343\/revisions\/1820"}],"wp:attachment":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=343"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}