3

I've had an impression it was some go-to way of encapsulating complex SQL logic. But digging related responses, such as this one, it doesn't seem to be the case.
So are CREATE PROCEDURE-related tweaks across versions just postgresql working towards aligning its behaviour with SQL spec? Even as of Postgresql 14 procedures have very limited usecases as it's unlikely to have an encapsulation-worthy logic with transaction control to return only a single row, considering the main job of DB is to wrangle sets of data around and a lot of CUD in CRUD operations work better with RETURNING clause.
Is there even a point of caring about FUNCTION/PROCEDURE distinction versus just using void returning functions for side-effects?

Biller Builder
  • 288
  • 1
  • 12

1 Answers1

3

Until PostgreSQL v11, PostgreSQL survived quite well without procedures, so they are indeed not absolutely necessary. The benefits are

  • more SQL standard compliance

  • a more natural way than RETURNS void for code that has no return value

  • the ability to run transactional commands like COMMIT and ROLLBACK in a procedure

The last benefit is of course the most important.

Laurenz Albe
  • 61,070
  • 4
  • 55
  • 90