Re: procedures and transactions

2019-02-21 Thread Peter Eisentraut
On 2019-02-20 17:45, Rob Nikander wrote: >> On Feb 20, 2019, at 10:07 AM, Peter Eisentraut >> wrote: >> >> You can run SET TRANSACTION ISOLATION LEVEL in a procedure. > > I tried that before but I get this error: > > create or replace procedure t_test(n integer) > as $$ > begin

Re: procedures and transactions

2019-02-20 Thread Rob Nikander
> On Feb 20, 2019, at 10:07 AM, Peter Eisentraut > wrote: > > You can run SET TRANSACTION ISOLATION LEVEL in a procedure. I tried that before but I get this error: create or replace procedure t_test(n integer) as $$ begin set transaction isolation level serializable;

Re: procedures and transactions

2019-02-20 Thread Peter Eisentraut
On 2019-02-19 22:48, Rob Nikander wrote: > I thought if I had some application logic that needed a certain kind of > transaction (maybe a non-default isolation level), I could hide that > fact in a procedure. App code (Java/Python/whatever) could remain > unaware of transactions (except maybe

Re: procedures and transactions

2019-02-19 Thread Adrian Klaver
On 2/19/19 1:48 PM, Rob Nikander wrote: I thought if I had some application logic that needed a certain kind of transaction (maybe a non-default isolation level), I could hide that fact in a procedure. App code (Java/Python/whatever) could remain unaware of transactions (except maybe needing

Re: procedures and transactions

2019-02-19 Thread Rob Nikander
I thought if I had some application logic that needed a certain kind of transaction (maybe a non-default isolation level), I could hide that fact in a procedure. App code (Java/Python/whatever) could remain unaware of transactions (except maybe needing to retry after a failure) and simply send

Re: procedures and transactions

2019-02-19 Thread Adrian Klaver
On 2/19/19 12:31 PM, Rob Nikander wrote: Hi, I’m trying to understand how procedures work with transactions. I tried the code below - it’s a simple procedure to print some notices and commit a transaction. If I call it from psql after a `begin`, then it gives an error. What does that error

Re: procedures and transactions

2019-02-19 Thread David G. Johnston
On Tuesday, February 19, 2019, Rob Nikander wrote: > Are procedures not allowed to commit/rollback if they are called within > in an outer transaction? > https://www.postgresql.org/docs/11/sql-call.html Also, I tried putting a `start transaction` command in the procedure. I got > another

procedures and transactions

2019-02-19 Thread Rob Nikander
Hi, I’m trying to understand how procedures work with transactions. I tried the code below - it’s a simple procedure to print some notices and commit a transaction. If I call it from psql after a `begin`, then it gives an error. What does that error mean? Are procedures not allowed to commit