{"id":975,"date":"2021-09-23T11:21:05","date_gmt":"2021-09-23T15:21:05","guid":{"rendered":"https:\/\/folvera.commons.gc.cuny.edu\/?p=975"},"modified":"2021-09-23T11:21:05","modified_gmt":"2021-09-23T15:21:05","slug":"cuny-ace-upskilling-introduction-to-structured-query-language-sf21job-day-9","status":"publish","type":"post","link":"https:\/\/folvera.commons.gc.cuny.edu\/?p=975","title":{"rendered":"CUNY ACE Upskilling: Introduction to Structured Query Language (SF21JOB) \u2014 Day 9"},"content":{"rendered":"<p>We have reached the end of the course with the introduction of functions.<\/p>\n<pre><span style=\"color: #0000ff\">    CREATE FUNCTION<\/span> quick_example(<span class=\"\">@<\/span>in_param <span style=\"color: #0000ff\">VARCHAR<\/span>(50))\r\n      <span style=\"color: #339966\">-- passing a value into the function using parameter\r\n      -- `@in_param` declared as a VARCHAR(50)<\/span>\r\n    <span style=\"color: #0000ff\">RETURNS VARCHAR<\/span>(50)\r\n    <span style=\"color: #0000ff\">AS<\/span>\r\n      <span style=\"color: #0000ff\">BEGIN<\/span>\r\n      <span style=\"color: #339966\">-- beginning of code do something when executing this \r\n      -- function<\/span>\r\n        <span style=\"color: #0000ff\">DECLARE<\/span> @out_param <span style=\"color: #0000ff\">VARCHAR<\/span>(50)\r\n            <span style=\"color: #339966\">-- receive value from it has been processed, using \r\n            -- the same data type (VARCHAR(50))<\/span>\r\n        <span style=\"color: #0000ff\">SET<\/span> @out_param = <span style=\"color: #ff00ff\">CONCAT<\/span> (\r\n            <span style=\"color: #ff0000\">'`'<\/span>,\r\n            @in_param,\r\n            <span style=\"color: #ff0000\">'` processed as `'<\/span>,\r\n            <span style=\"color: #ff00ff\">UPPER<\/span>(@in_param),\r\n            <span style=\"color: #ff0000\">'`'<\/span>\r\n            )\r\n            <span style=\"color: #339966\">-- passing a value. the original value processed<\/span>\r\n        <span style=\"color: #0000ff\">RETURN<\/span> @out_param\r\n            <span style=\"color: #339966\">-- printing the value of the output parameter<\/span>\r\n      <span style=\"color: #339966\">-- end of code to do something when executing this function<\/span>\r\n      <span style=\"color: #0000ff\">END;\r\n<\/span><\/pre>\n<p>Download the\u00a0<a title=\"Class Notes for SF21JOB - Day 9 (2021\/09\/22)\" href=\"https:\/\/folvera.commons.gc.cuny.edu\/wp-content\/blogs.dir\/2501\/files\/2021\/09\/SF21JOB_20210922.pdf\">class notes<\/a> for day 9.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have reached the end of the course with the introduction of functions. CREATE FUNCTION quick_example(@in_param VARCHAR(50)) &#8212; passing a value into the function using parameter &#8212; `@in_param` declared as a VARCHAR(50) RETURNS VARCHAR(50) AS BEGIN &#8212; beginning of code do something when executing this &#8212; function DECLARE @out_param VARCHAR(50) &#8212; receive value from it [&hellip;]<\/p>\n","protected":false},"author":7213,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"send_to_group_blog":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-975","post","type-post","status-publish","format-standard","hentry","category-cuny"],"_links":{"self":[{"href":"https:\/\/folvera.commons.gc.cuny.edu\/index.php?rest_route=\/wp\/v2\/posts\/975","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/folvera.commons.gc.cuny.edu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/folvera.commons.gc.cuny.edu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/folvera.commons.gc.cuny.edu\/index.php?rest_route=\/wp\/v2\/users\/7213"}],"replies":[{"embeddable":true,"href":"https:\/\/folvera.commons.gc.cuny.edu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=975"}],"version-history":[{"count":1,"href":"https:\/\/folvera.commons.gc.cuny.edu\/index.php?rest_route=\/wp\/v2\/posts\/975\/revisions"}],"predecessor-version":[{"id":978,"href":"https:\/\/folvera.commons.gc.cuny.edu\/index.php?rest_route=\/wp\/v2\/posts\/975\/revisions\/978"}],"wp:attachment":[{"href":"https:\/\/folvera.commons.gc.cuny.edu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/folvera.commons.gc.cuny.edu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/folvera.commons.gc.cuny.edu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}