Procedural Constructs
Although SQL is a declarative language, it does have procedural features: stored procedures, triggers, and cursors. Stored procedures, or more properly, Persistent Stored Modules (SQL/PSM), give SQL its own 4GL programming language. Triggers are stored procedures attached to one table and controlled by database events such as inserts, updates, and deletes on it. Cursors convert a query, update, or delete statement into a sequential file structure that can be accessed one row at a time.
We will now discuss each one in more detail, but you will find that stored procedures are by far the most useful of the three. Triggers exist because the early SQL Standards did not have declarative referential integrity (DRI) actions. Later ...
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