One of the most fundamental constructs of any programming language is the function. Broadly speaking, a function is any unit of code that accomplishes a defined task. Functions are also referred to, depending on the language being used, as procedures, routines, or methods. In this section, we introduce the concept of a function and see how we can use them to transform database data.
A function allows a program to be structured into separate components, increasing the modularity, readability, and reusability of code. With functions, we are freed from the limitations of creating programs that simply execute one command after another in a purely linear fashion. Functions allow the grouping of code into discreet elements to accomplish a particular action. Functions adhere to different rules and definitions that vary between programming languages, so it is important to distinguish how the SQL language implements functions...