Force Commit

Started by İlyas Derseabout 6 years ago3 messagesgeneral
Jump to latest
#1İlyas Derse
ilyasderse@gmail.com

I'm writing to you about Commit. I want to do force commit query even if
I have exception.
It's like :

CREATE OR REPLACE PROCEDURE public."test"()
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE "a" integer ;
DECLARE "b" integer ;
BEGIN
"a" = 1;
"b" = 0;
BEGIN
raise notice 'hata';
update public."crud" set lastname = 'Tekindor' where autoid = 20;
"a"="a"/"b";
ROLLBACK;

EXCEPTION
WHEN OTHERS THEN

COMMIT;
END ;
END ;
$BODY$;

How can I do force commit ?
Thanks..

#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: İlyas Derse (#1)
Re: Force Commit

st 5. 2. 2020 v 9:10 odesílatel İlyas Derse <ilyasderse@gmail.com> napsal:

I'm writing to you about Commit. I want to do force commit query even
if I have exception.
It's like :

CREATE OR REPLACE PROCEDURE public."test"()
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE "a" integer ;
DECLARE "b" integer ;
BEGIN
"a" = 1;
"b" = 0;
BEGIN
raise notice 'hata';
update public."crud" set lastname = 'Tekindor' where autoid = 20;
"a"="a"/"b";
ROLLBACK;

EXCEPTION
WHEN OTHERS THEN

COMMIT;
END ;
END ;
$BODY$;

How can I do force commit ?
Thanks..

just you cannot to do it.

There is not possibility how to do it now.

Regards

Pavel

#3Andrei Zhidenkov
andrei.zhidenkov@n26.com
In reply to: İlyas Derse (#1)
Re: Force Commit

You can workaround by simulation autonomous transaction using plpython or dblink. Or just performing a commit outside the stored procedure.

Show quoted text

On 5. Feb 2020, at 09:06, İlyas Derse <ilyasderse@gmail.com> wrote:

I'm writing to you about Commit. I want to do force commit query even if I have exception.
It's like :

CREATE OR REPLACE PROCEDURE public."test"()
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE "a" integer ;
DECLARE "b" integer ;
BEGIN
"a" = 1;
"b" = 0;
BEGIN
raise notice 'hata';
update public."crud" set lastname = 'Tekindor' where autoid = 20;
"a"="a"/"b";
ROLLBACK;

EXCEPTION
WHEN OTHERS THEN

COMMIT;
END ;
END ;
$BODY$;

How can I do force commit ?
Thanks..