1 PL/pgSQL Under the Hood This part discusses some implementation details that are frequently important for PL/pgSQL users to know. 1.1 Variable Substitution SQL statements and expressions within a PL/pgSQL function can refer to variables and paramet…
Trigger Procedures PL/pgSQL can be used to define trigger procedures on data changes or database events. A trigger procedure is created with the CREATE FUNCTION command, declaring it as a function with no arguments and a return type of trigger (for d…
Control Structures of PL/SQL Control structures are probably the most useful (and important) part of PL/pgSQL.With PL/pgSQL's control structures, you can manipulate PostgreSQL data in a very flexible and powerful way. 1.Returning From a Function RETU…
Cursors Rather than executing a whole query at once, it is possible to set up a cursor that encapsulates the query, and then read the query result a few rows at a time. A more interesting usage is to return a reference to a cursor that a function has…
1.Structure of PL/pgSQL The structure of PL/pgSQL is like below: [ <<label>> ] [ DECLARE declarations ] BEGIN statements END [ label ]; A label is only needed if you want to identify the block for use in an EXIT statement, or to qualify the na…