Functions or Procedures? What's the Difference?
The literature differentiates between different programming styles, such as object-oriented, event-oriented, function-oriented, and procedure-oriented. In PostgreSQL, we use mostly function-oriented or procedure-oriented approaches. The PostgreSQL LISTEN command also provides a tool to support event-based approaches.Often, function-oriented approaches are described as deterministic, meaning they return the same value for the same inputs, avoiding side effects and not changing global data structures. Procedural approaches focus on changing global variables or data structures, and not on return values.Functions in PostgreSQL have return values, but they can also modify the environment (that is, make changes to the database state), and their return value is not only determined by the input parameters, except for IMMUTABLE functions, which do not access the database and determine the return result only based on the input parameters.The...