Part V. Procedural Database Objects

In Section 1.4, in Chapter 1, “Introduction to SQL,” we stated that for a long time SQL was a purely declarative language, but this changed in 1986–1987 when Sybase came onto the market. With this product, the first commercial implementation of the stored procedure became a fact, and that changed the character of SQL. A stored procedure can informally be described as a piece of code that can be activated; this piece of code consists of well-known SQL statements, such as INSERT and SELECT, but also procedural statements, such as IF-THEN-ELSE. Because stored procedures offered many practical advantages, other vendors started to implement them, too. This meant the end of the pure declarative character of SQL. Since their inclusion in the SQL2 standard, stored procedures have formed a real part of the language.

Later, other nondeclarative database objects were added, such as stored functions and triggers. These are all database objects that we create with CREATE statements and store in the catalog. They differ, however, because they are based on procedural code. That is why we call them procedural database objects.

Because nowadays all important SQL products support these objects, we devote this entire section to this subject. We describe stored procedures, stored functions, and triggers.

Portability

Procedural database objects were added to the SQL2 standard after the vendors had implemented them. The negative effect of this has been that not one product implements the standard precisely. Vendors had to select a language before the standardization committee had finished. It should also be noted that, unfortunately, the products do not use the same syntax. In some cases, the syntactical differences are enormous. Oracle, for example, uses the language PL/SQL, Sybase and Microsoft SQL Server use the language Transact-SQL, and other products allow stored procedures to be formulated in well-known languages such as C and Java. The features that the products support with respect to stored procedures and triggers also differ greatly. In this part, we selected the syntax of MySQL so that you can run the examples.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.39.142