Db2 SQL PL, triggers, stored procedures & user-defined functions

Since quite some time now, the possibility exists to integrate extra functionality in your database by means of stored procedures, triggers and user defined functions. Meanwhile, these features have proven to be indispensable, especially for improving modularity, reusability, and security. Time for you to start using these functional objects!

In this course the advantages and disadvantages of stored procedures, triggers and user defined functions are explained. Participants also learn to apply the right tool.

Participants will also get a technical insight in the set-up and the use of stored procedures, triggers and user-defined functions. Both external stored procedures and stored procedures set-up with SQL PL (the 'SQL procedural language') are discussed. The SQL PL language is treated in sufficient depth such that participants will be able to write even fairly complex procedures. For those who want to go deeper into SQL PL, we refer to the course SQL PL database programming


No public sessions are currently scheduled. We will be pleased to set up an on-site course or to schedule an extra public session (in case of a sufficient number of candidates). Interested? Please let us know.

Intended for

Application developers and technical analysts who have to develop stored procedures, triggers or user defined functions.

DBAs and data base designers who want to know the new possibilities in Db2 and learn how triggers and stored procedures can help implement the logical design, the data integrity, and the access control of a relational database.


Participants should be familiar with SQL (see SQL and relational databases fundamentals) and with Db2 for z/OS (see Db2 for z/OS fundamentals course) or Db2 for Linux, Unix and Windows (see Db2 for LUW fundamentals course). Knowledge of an application programming language (COBOL, PL/I, C, Java, SQL PL, ...) is not required.

Main topics

  • SQL PL:
  • The procedural language of Db2: a short introduction
  • How to use variables, create cursors, throw exceptions, verify conditions, ...
  • Triggers:
  • What are triggers?
  • How and when do we use triggers?
  • Writing triggers
  • Examples and exercises
  • Stored procedures:
  • What are stored procedures: advantages and disadvantages?
  • When do we use stored procedures?
  • External stored procedures (written in COBOL, PL/I, C, Java, ...)
  • "Native" stored procedures: written in SQL PL
  • Examples and exercises
  • User defined functions:
  • User defined functions: introduction
  • How do we implement user defined functions?
  • When and how to use UDFs?
  • Scalar functions and table functions
  • Native functions versus external ones (written in COBOL, PL/I, C, Java, ...)
  • Examples and exercises

Training method

Classroom instruction with examples and exercises.


1 day.

Course leader

Peter Vanroose.