{"id":1382,"date":"2012-05-25T13:52:47","date_gmt":"2012-05-25T13:52:47","guid":{"rendered":"http:\/\/galhano.com\/blog\/?p=1382"},"modified":"2012-05-25T13:53:57","modified_gmt":"2012-05-25T13:53:57","slug":"mysql-create-function-syntax","status":"publish","type":"post","link":"http:\/\/galhano.com\/blog\/?p=1382","title":{"rendered":"MySQL, CREATE FUNCTION Syntax"},"content":{"rendered":"<p><strong>The general syntax of Creating a Function is :<\/strong><\/p>\n<p>[sql] CREATE FUNCTION func_name ([func_parameter[,&#8230;]]) RETURNS type routine_body[\/sql]<\/p>\n<p>func_name : Function name<br \/>\nfunc_parameter : param_name type<br \/>\ntype : Any valid MySQL datatype<br \/>\nroutine_body : Valid SQL procedure statement<\/p>\n<p><strong>\u00a0The RETURN clause is mandatory for FUNCTION<\/strong> . It used to indicate the return type of function.<\/p>\n<p>Now we are describing you a simple example a function. This function take a parameter and it is used to perform an operation by using an SQL function and return the result. In this example there is no need to use delimiter because it contains no internal ; statement delimiters. Example :<\/p>\n<p>[sql]<br \/>\nCREATE FUNCTION func(str CHAR(20))<br \/>\nRETURNS CHAR(50)<br \/>\nRETURN CONCAT(&#8216;WELCOME TO, &#8216;,str,&#8217;!&#8217;);<br \/>\n[\/sql]<\/p>\n<p>Query OK, 0 rows affected (0.00 sec)<\/p>\n<p>[sql] SELECT func(&#8216;Galhano.com&#8217;);[\/sql]<\/p>\n<p>&nbsp;<\/p>\n<p>[text]<br \/>\n+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\n| func(&#8216;Galhano.com&#8217;)\u00a0\u00a0\u00a0\u00a0\u00a0 |<br \/>\n+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\n| WELCOME TO, Galhano.com |<br \/>\n+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\n1 row in set (0.00 sec)<br \/>\n[\/text]<\/p>\n<p>http:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/create-procedure.html<\/p>\n<p>http:\/\/www.roseindia.net\/mysql\/mysql5\/stored-procedures-and-functions.shtml<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The general syntax of Creating a Function is : [sql] CREATE FUNCTION func_name ([func_parameter[,&#8230;]]) RETURNS type routine_body[\/sql] func_name : Function name func_parameter : param_name type type : Any valid MySQL datatype routine_body : Valid SQL procedure statement \u00a0The RETURN clause is mandatory for FUNCTION . It used to indicate the return type of function. Now [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"close","ping_status":"close","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1382","post","type-post","status-publish","format-standard","hentry","category-mysql","author-admin"],"_links":{"self":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1382","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=1382"}],"version-history":[{"count":4,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1382\/revisions"}],"predecessor-version":[{"id":1386,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1382\/revisions\/1386"}],"wp:attachment":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1382"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}