﻿{"id":933,"date":"2016-11-15T11:12:18","date_gmt":"2016-11-15T03:12:18","guid":{"rendered":"http:\/\/www.oracle.name\/?p=933"},"modified":"2016-11-25T17:29:38","modified_gmt":"2016-11-25T09:29:38","slug":"oracle-plsql-%e8%a1%8c%e5%90%88%e5%b9%b6","status":"publish","type":"post","link":"https:\/\/www.llku.com\/?p=933","title":{"rendered":"Oracle PLSQL \u884c\u5408\u5e76"},"content":{"rendered":"<p>\n\tselect created_by, translate(ltrim(text, &#39;\/&#39;), &#39;*\/&#39;, &#39;*,&#39;) researcherlist<br \/>\n\t&nbsp; from (select row_number() over(partition by created_by order by created_by, lvl desc) rn,<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; created_by,<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from (select created_by,<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; level lvl,<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sys_connect_by_path(c_researcher_code, &#39;\/&#39;) text<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from (select created_by,<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; user_name as c_researcher_code,<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; row_number() over(partition by created_by order by created_by, user_name) x<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from fnd_user<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; order by created_by, user_name) a<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connect by created_by = prior created_by<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and x &#8211; 1 = prior x))<br \/>\n\t&nbsp;where rn = 1<br \/>\n\t&nbsp;order by created_by;\n<\/p>\n<p>\n\t<span style=\"widows: 1; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 13px\/19px Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; float: none; letter-spacing: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px\">SQL\u5206\u6790\uff1a<\/span>\n<\/p>\n<p>\n\t<span style=\"widows: 1; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 13px\/19px Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; float: none; letter-spacing: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px\">1\u3001\u5229\u7528 &ldquo;ROW_NUMBER () OVER (PARTITION BY&hellip;&hellip;&rdquo; \u4e3a\u6309&ldquo;\u521b\u5efa\u4eba&rdquo;\u6c47\u603b\u540e\u7684\u6570\u636e\u884c\u6dfb\u52a0\u7ec4\u5185\u5e8f\u53f7<\/span>\n<\/p>\n<p>\n\t<span style=\"widows: 1; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 13px\/19px Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; float: none; letter-spacing: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px\">2\u3001&ldquo;SYS_CONNECT_BY_PATH&rdquo;&nbsp; \u6309\u7ec4\u5185\u5e8f\u53f7\u76f8\u90bb\u5173\u7cfb\uff0c\u4e3a\u6bcf\u4e00\u5c42\u8fdb\u884c\u4e0d\u540c\u884c\u7684&ldquo;\u540d\u79f0&rdquo;\u53e0\u52a0<\/span>\n<\/p>\n<p>\n\t<span style=\"widows: 1; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 13px\/19px Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; float: none; letter-spacing: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px\">3\u3001\u518d\u6b21\u5229\u7528&ldquo;<\/span>\u521b\u5efa\u4eba<span style=\"widows: 1; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 13px\/19px Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; float: none; letter-spacing: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px\">&rdquo;\u8fdb\u884c\u7ec4\u5185\u5206\u7ec4\uff0c\u4f46\u6309\u7b2c\u4e8c\u90e8\u4e2d\u7684\u5c42\u6b21\u6392\u5012\u5e8f\uff0c\u589e\u52a0\u8c03\u6574\u540e\u7b49\u7ea7<\/span>\n<\/p>\n<p>\n\t<span style=\"widows: 1; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 13px\/19px Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; float: none; letter-spacing: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px\">4\u3001\u53d6\u6240\u6709\u8c03\u6574\u540e\u7b49\u7ea7\u4e3a1\u7684\u7ed3\u679c\uff0c\u5373\u4e3a\u6240\u8981\u6c42\u7684\u6570\u636e\u884c<\/span>\n<\/p>\n<p>\n\t<span style=\"widows: 1; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 13px\/19px Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; float: none; letter-spacing: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px\">\u5176\u4ed6\u53c2\u8003\uff1a<\/span><a href=\"http:\/\/www.ningoo.net\/html\/2008\/how_to_do_string_aggregate_on_oracle.html\">http:\/\/www.ningoo.net\/html\/2008\/how_to_do_string_aggregate_on_oracle.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>select created_by, translate(ltrim(text, &#39;\/&#39;),  &hellip; <a href=\"https:\/\/www.llku.com\/?p=933\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Oracle PLSQL \u884c\u5408\u5e76<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[144],"_links":{"self":[{"href":"https:\/\/www.llku.com\/index.php?rest_route=\/wp\/v2\/posts\/933"}],"collection":[{"href":"https:\/\/www.llku.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.llku.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.llku.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.llku.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=933"}],"version-history":[{"count":6,"href":"https:\/\/www.llku.com\/index.php?rest_route=\/wp\/v2\/posts\/933\/revisions"}],"predecessor-version":[{"id":943,"href":"https:\/\/www.llku.com\/index.php?rest_route=\/wp\/v2\/posts\/933\/revisions\/943"}],"wp:attachment":[{"href":"https:\/\/www.llku.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=933"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.llku.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=933"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.llku.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=933"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}