PL/pgSQL A procedural language for the PostgreSQL RDBMS Jan Wieck Preface PL/pgSQL is a procedural language based on SQL designed for the PostgreSQL database system. The extensibility features of PostgreSQL are mostly based on the ability to define functions for various operations. Functions could have been written in PostgreSQL's SQL dialect or in the C programming language. Functions written in C are compiled into a shared object and loaded by the database backend process on demand. Also the trigger features of PostgreSQL are based on functions but required the use of the C language. Since version 6.3 PostgreSQL supports the definition of procedural languages. In the case of a function or trigger procedure defined in a procedural language, the database has no builtin knowlege how to interpret the functions source text. Instead, the function and trigger calls are passed into a handler that knows the details of the language. The handler itself is a function compiled into a shared object and loaded on demand. Overview The PL/pgSQL language is case insensitive. All keywords and identifiers can be used in upper-/lowercase mixed. PL/pgSQL is a block oriented language. A block is defined as [<