O'Reilly logo

SQL Bible, Second Edition by Boris M. Trukhnov, Alex Kriegel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required