{"id":1983,"date":"2015-10-13T09:49:31","date_gmt":"2015-10-13T09:49:31","guid":{"rendered":"http:\/\/galhano.com\/blog\/?p=1983"},"modified":"2015-10-13T09:49:31","modified_gmt":"2015-10-13T09:49:31","slug":"mysql-proper-case","status":"publish","type":"post","link":"http:\/\/galhano.com\/blog\/?p=1983","title":{"rendered":"Mysql Proper Case"},"content":{"rendered":"<p> [sql]<br \/>\n    DROP FUNCTION IF EXISTS proper;<br \/>\n    SET GLOBAL  log_bin_trust_function_creators=TRUE;<br \/>\n    DELIMITER |<br \/>\n    CREATE FUNCTION proper( str VARCHAR(128) )<br \/>\n    RETURNS VARCHAR(128)<br \/>\n    BEGIN<br \/>\n      DECLARE c CHAR(1);<br \/>\n      DECLARE s VARCHAR(128);<br \/>\n      DECLARE i INT DEFAULT 1;<br \/>\n      DECLARE bool INT DEFAULT 1;<br \/>\n      DECLARE punct CHAR(17) DEFAULT &#8216; ()[]{},.-_!@;:?\/&#8217;;<br \/>\n      SET s = LCASE( str );<br \/>\n      WHILE i &lt; LENGTH( str ) DO<br \/>\n        BEGIN<br \/>\n          SET c = SUBSTRING( s, i, 1 );<br \/>\n          IF LOCATE( c, punct ) &gt; 0 THEN<br \/>\n            SET bool = 1;<br \/>\n          ELSEIF bool=1 THEN<br \/>\n            BEGIN<br \/>\n              IF c &gt;= &#8216;a&#8217; AND c &lt;= &#8216;z&#8217; THEN<br \/>\n                BEGIN<br \/>\n                  SET s = CONCAT(LEFT(s,i-1),UCASE(c),SUBSTRING(s,i+1));<br \/>\n                  SET bool = 0;<br \/>\n                END;<br \/>\n              ELSEIF c &gt;= &#8216;0&#8217; AND c &lt;= &#8216;9&#8217; THEN<br \/>\n                SET bool = 0;<br \/>\n              END IF;<br \/>\n            END;<br \/>\n          END IF;<br \/>\n          SET i = i+1;<br \/>\n        END;<br \/>\n      END WHILE;<br \/>\n      RETURN s;<br \/>\n    END;<br \/>\n    |<br \/>\n    DELIMITER ;<br \/>\n[\/sql]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[sql] DROP FUNCTION IF EXISTS proper; SET GLOBAL log_bin_trust_function_creators=TRUE; DELIMITER | CREATE FUNCTION proper( str VARCHAR(128) ) RETURNS VARCHAR(128) BEGIN DECLARE c CHAR(1); DECLARE s VARCHAR(128); DECLARE i INT DEFAULT 1; DECLARE bool INT DEFAULT 1; DECLARE punct CHAR(17) DEFAULT &#8216; ()[]{},.-_!@;:?\/&#8217;; SET s = LCASE( str ); WHILE i &lt; LENGTH( str ) DO [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"close","ping_status":"close","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,8,40],"tags":[],"class_list":["post-1983","post","type-post","status-publish","format-standard","hentry","category-code-snippets","category-mysql","category-sql","author-admin"],"_links":{"self":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1983","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1983"}],"version-history":[{"count":1,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1983\/revisions"}],"predecessor-version":[{"id":1984,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1983\/revisions\/1984"}],"wp:attachment":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1983"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}