January 2019
Beginner
556 pages
14h 19m
English
In PostgreSQL 11, procedures were introduced. The main difference between functions and procedures is transaction control. Functions are explicitly run in a transaction, while a procedure can control transactions. In procedures, you can explicitly COMMIT and ROLLBACK a transaction. Functions can be called within SQL code, but procedures are executed via CALL statements. Finally, functions should have a return data type; if the function does not return anything, the VOID pseudo data type can be used.
Procedures have great benefits. Let's suppose that we would like to index all foreign keys. In this case, using a function is not very practical, because the indexes are created when the function completely ...
Read now
Unlock full access