Jeremiasz Miedzinski wrote:
I'm digging into postgresql documentation but maybe I'm just not smart enough to understand the way which transactions are being processed into pgSQL. Is it possible to port above code to PL/pgSQL ?
All functions, including pl/pgsql functions take place within a transaction. You cannot commit, but you can catch errors and roll back to savepoints within a transaction.
If you want to have multiple transactions you will need to step outside of the database.
It's not clear to me why your function does what it does anyway. I can't see why you wouldn't just do this as standard queries.
-- Richard Huxton Archonet Ltd