Chapter 14. Stored Procedures, Triggers, and User-Defined Functions
As we have already mentioned, SQL is a nonprocedural programming language by definition. As such, it lacks procedural constructs, specifically, the ability to perform operations in (optionally named) hierarchical logical blocks that can accept and return values, perform iterations, execute conditional statements, and so on.
Note
Most programming languages are procedural. A procedural program is essentially a list of step-by-step instructions that tell the computer what to do. For example, a procedural program tells a computer to repeatedly read user's input, multiply it by some predefined constant, and store the result in a database table. A procedural program can also have error handling. For example, if the value is nonnumeric an error message will be displayed, but the program will continue. Also, instead of storing the result in a table, a procedural program can pass it to a different program (subprogram) that, in its turn, might perform more calculations and pass the results to yet another programming module, and so on.
The first RDBMS implementations did not have procedural language capabilities — all procedural data processing was done using embedded programming. All major procedural languages that were popular back then (C, COBOL, Pascal, and so on) had (and still have) special extensions (precompilers) that allowed the programmer to embed SQL statements directly into programming language code. The work of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access