{"id":427,"date":"2007-10-27T00:00:00","date_gmt":"2007-10-27T00:00:00","guid":{"rendered":"http:\/\/www.strongd.net\/?p=427"},"modified":"2007-10-27T00:00:00","modified_gmt":"2007-10-27T00:00:00","slug":"BEGIN and END Statements","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=427","title":{"rendered":"BEGIN and END Statements"},"content":{"rendered":"<p><H1><CODE><FONT size=4><FONT color=#000000>mysql&gt;<\/FONT><BR><FONT color=#000000>mysql&gt;&nbsp;DELIMITER&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/<\/FONT><BR><FONT color=#000000>mysql&gt;&nbsp;<\/FONT><FONT color=#7f0055>CREATE&nbsp;<\/FONT><FONT color=#000000>FUNCTION&nbsp;myProc&nbsp;<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>cost&nbsp;DECIMAL<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#990000>10<\/FONT><FONT color=#000000>,<\/FONT><FONT color=#990000>2<\/FONT><FONT color=#000000>))<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>-&gt;&nbsp;RETURNS&nbsp;DECIMAL<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#990000>10<\/FONT><FONT color=#000000>,<\/FONT><FONT color=#990000>2<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>-&gt;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>-&gt;&nbsp;SQL&nbsp;SECURITY&nbsp;DEFINER<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>-&gt;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>-&gt;&nbsp;tax:&nbsp;<\/FONT><FONT color=#7f0055>BEGIN<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>-&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DECLARE&nbsp;order_tax&nbsp;DECIMAL<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#990000>10<\/FONT><FONT color=#000000>,<\/FONT><FONT color=#990000>2<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>-&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SET&nbsp;order_tax&nbsp;=&nbsp;cost&nbsp;*&nbsp;<\/FONT><FONT color=#990000>.05<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>-&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RETURN&nbsp;order_tax;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>-&gt;&nbsp;<\/FONT><FONT color=#7f0055>END<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>-&gt;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/<\/FONT><BR><FONT color=#000000>Query&nbsp;OK,&nbsp;<\/FONT><FONT color=#990000>0&nbsp;<\/FONT><FONT color=#000000>rows&nbsp;affected&nbsp;<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#990000>0.00&nbsp;<\/FONT><FONT color=#000000>sec<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#000000>mysql&gt;&nbsp;DELIMITER&#038;nbsp$$<\/FONT><BR><FONT color=#000000>mysql&gt;<\/FONT><BR><FONT color=#000000>mysql&gt;&nbsp;<\/FONT><FONT color=#7f0055>select&nbsp;<\/FONT><FONT color=#000000>myProc<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#990000>123.45<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#000000>+&#8212;&#8212;&#8212;&#8212;&#8212;-+<\/FONT><BR><FONT color=#000000>|&nbsp;myProc<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#990000>123.45<\/FONT><FONT color=#000000>)&nbsp;<\/FONT><FONT color=#000000>|<\/FONT><BR><FONT color=#000000>+&#8212;&#8212;&#8212;&#8212;&#8212;-+<\/FONT><BR><FONT color=#000000>|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#990000>6.17&nbsp;<\/FONT><FONT color=#000000>|<\/FONT><BR><FONT color=#000000>+&#8212;&#8212;&#8212;&#8212;&#8212;-+<\/FONT><BR><FONT color=#990000>1&nbsp;<\/FONT><FONT color=#000000>row&nbsp;in&nbsp;set,&nbsp;<\/FONT><FONT color=#990000>1&nbsp;<\/FONT><FONT color=#000000>warning&nbsp;<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#990000>0.00&nbsp;<\/FONT><FONT color=#000000>sec<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#000000>mysql&gt;<\/FONT><BR><FONT color=#000000>mysql&gt;&nbsp;drop&nbsp;<\/FONT><FONT color=#7f0055>function&nbsp;<\/FONT><FONT color=#000000>myProc;<\/FONT><BR><FONT color=#000000>Query&nbsp;OK,&nbsp;<\/FONT><FONT color=#990000>0&nbsp;<\/FONT><FONT color=#000000>rows&nbsp;affected&nbsp;<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#990000>0.00&nbsp;<\/FONT><FONT color=#000000>sec<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#000000>mysql&gt;<\/FONT><\/FONT><\/CODE><\/H1><br \/>\n<DIV><FONT size=4><\/FONT><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>mysql&gt;mysql&gt;&nbsp;DELIMITER&nbsp;\/\/mysql&gt;&nbsp;CREATE&nbsp;FUNCTION&nbsp;myProc&nbsp;(cost&nbsp;DECIMAL(10,2))&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;RETURNS&nbsp;DECIMAL(10,2)&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;SQL&nbsp;SECURITY&nbsp;DEFINER&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;tax:&nbsp;BEGIN&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DECLARE&nbsp;order_tax&nbsp;DECIMAL(10,2);&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SET&nbsp;order_tax&nbsp;=&nbsp;cost&nbsp;*&nbsp;.05;&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RETURN&nbsp;order_tax;&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;END&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;\/\/Query&nbsp;OK,&nbsp;0&nbsp;rows&nbsp;affected&nbsp;(0.00&nbsp;sec)mysql&gt;&nbsp;DELIMITER&#038;nbsp$$mysql&gt;mysql&gt;&nbsp;select&nbsp;myProc(123.45);+&#8212;&#8212;&#8212;&#8212;&#8212;-+|&nbsp;myProc(123.45)&nbsp;|+&#8212;&#8212;&#8212;&#8212;&#8212;-+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6.17&nbsp;|+&#8212;&#8212;&#8212;&#8212;&#8212;-+1&nbsp;row&nbsp;in&nbsp;set,&nbsp;1&nbsp;warning&nbsp;(0.00&nbsp;sec)mysql&gt;mysql&gt;&nbsp;drop&nbsp;function&nbsp;myProc;Query&nbsp;OK,&nbsp;0&nbsp;rows&nbsp;affected&nbsp;(0.00&nbsp;sec)mysql&gt;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-427","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/427","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=427"}],"version-history":[{"count":0,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/427\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}