{"id":49,"date":"2013-10-02T16:36:00","date_gmt":"2013-10-02T16:36:00","guid":{"rendered":"\/colin\/morethanfour\/post\/Implementing-a-Proper()-case-function-in-PLSQL"},"modified":"2013-10-02T16:36:00","modified_gmt":"2013-10-02T16:36:00","slug":"implementing-a-proper-case-function-in-pl-sql","status":"publish","type":"post","link":"https:\/\/spacefold.com\/colin\/morethanfour\/2013\/10\/02\/implementing-a-proper-case-function-in-pl-sql\/","title":{"rendered":"Implementing a Proper() case function in PL\/SQL"},"content":{"rendered":"<p>I found that I needed to convert some raw column names (i.e. THIS_IS_MY_COLUMN) into a human-readable &#8220;Proper&#8221; or &#8220;Title&#8221; case form, e.g. This Is My Column.<\/p>\n<p>Scouring the web, I didn&#8217;t find out I could steal, so here&#8217;s my implementation:<\/p>\n<pre>   function Proper(<br \/>      p_string varchar2<br \/>   ) return varchar2<br \/>   is<br \/>      l_string varchar2(200);<br \/>      l_proper varchar2(200);   <br \/>   begin<br \/>      l_proper := '';<br \/>     <span style=\"color: #339966;\"> -- change any underscores to spaces:<\/span><br \/>      l_string := replace(lower(p_string), '_',' ' );<br \/><br \/>      for i in 1..length(l_string)<br \/>      loop<br \/>         <span style=\"color: #339966;\">-- obviously the first character is UPPER:<\/span><br \/>         if i =1 then<br \/>            l_proper := l_proper || upper( substr( l_string, i, 1 ) );<br \/>         else<br \/>         <span style=\"color: #339966;\">-- if the character is preceded by a space, UPPER it:<\/span><br \/>            if substr( l_string, i-1, 1 ) = ' ' then<br \/>               l_proper := l_proper || upper( substr( l_string, i, 1 ) );<br \/>            else<br \/>               l_proper := l_proper || substr( l_string, i, 1 );<br \/>            end if;            <br \/>         end if;   <br \/>      end loop;<br \/>      return l_proper;<br \/>   end;<\/pre>\n<pre> <\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I found that I needed to convert some raw column names (i.e. THIS_IS_MY_COLUMN) into a human-readable &#8220;Proper&#8221; or &#8220;Title&#8221; case form, e.g. This Is My Column. Scouring the web, I didn&#8217;t find out I could steal, so here&#8217;s my implementation: function Proper( p_string varchar2 ) return varchar2 is l_string varchar2(200); l_proper varchar2(200); begin l_proper := [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,16],"tags":[],"class_list":["post-49","post","type-post","status-publish","format-standard","hentry","category-oracle","category-sql-syntax","post-preview"],"_links":{"self":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts\/49","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/comments?post=49"}],"version-history":[{"count":0,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts\/49\/revisions"}],"wp:attachment":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/media?parent=49"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/categories?post=49"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/tags?post=49"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}