BUG #14241: i want to do commit and rollback in one plpgsql block..

Started by zubair alamover 9 years ago3 messagesbugs
Jump to latest
#1zubair alam
zzia88@gmail.com

The following bug has been logged on the website:

Bug reference: 14241
Logged by: Zubair Alam
Email address: zzia88@gmail.com
PostgreSQL version: 9.5.3
Operating system: windows7-x64(64 bit)
Description:

CREATE OR REPLACE FUNCTION DELROLL()
RETURNS INT AS $V_CHOICE$
BEGIN
IF V_CHOICE=1 THEN
DELETE FROM ITEMS
WHERE itemid=4;
--DBMS_OUTPUT.PUT_LINE('EMPLYEE RECORD DELETED
SUCESSFULLY');
END IF;
IF V_CHOICE=2 THEN
ROLLBACK;
COMMIT;
---DBMS_OUTPUT.PUT_LINE('ROLL BACK COMPLETED SUCESSFULLY');
END IF;
RETURN V_CHOICE;
END;
$V_CHOICE$
LANGUAGE PLPGSQL;

when i enter my choice 2 i.e for rollback and commit then that time this
error is generating.
ERROR: current transaction is aborted, commands ignored until end of
transaction block

********** Error **********

ERROR: current transaction is aborted, commands ignored until end of
transaction block
SQL state: 25P02

please give me perfect solution for using commit and rollback in one
plpgsql program block.

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: zubair alam (#1)
Re: BUG #14241: i want to do commit and rollback in one plpgsql block..

On Mon, Jul 11, 2016 at 3:32 AM, <zzia88@gmail.com> wrote:

The following bug has been logged on the website:

Bug reference: 14241
Logged by: Zubair Alam
Email address: zzia88@gmail.com
PostgreSQL version: 9.5.3
Operating system: windows7-x64(64 bit)
Description:

​This seems to be a duplicate of bug # 14240 which has already been
responded to.

David J.

#3David G. Johnston
david.g.johnston@gmail.com
In reply to: zubair alam (#1)
Re: BUG #14241: i want to do commit and rollback in one plpgsql block..

On Mon, Jul 11, 2016 at 9:40 AM, zubair alam <zzia88@gmail.com> wrote:

Please give me exact answer. i am waiting for solution. or tell how i have
to use in commit and rollback in one plpgsql block.
if you have knowledge then give me exact answer.

On Mon, Jul 11, 2016 at 4:14 PM, David G. Johnston <
david.g.johnston@gmail.com> wrote:

On Mon, Jul 11, 2016 at 3:32 AM, <zzia88@gmail.com> wrote:

The following bug has been logged on the website:

Bug reference: 14241
Logged by: Zubair Alam
Email address: zzia88@gmail.com
PostgreSQL version: 9.5.3
Operating system: windows7-x64(64 bit)
Description:

​This seems to be a duplicate of bug # 14240 which has already been
responded to.

David J.

​To quote the other reply:

"
Does not seem like a bug, IIRC commit/rollback is not allowed inside
functions ( savepoints are, you may try to work with them ).
​"

I'll just confirm this is true.

​That is as exact as you are going to get - at least from me.

​If you want more I suggest you reply to the original thread with
additional detail about what you are trying to accomplish. As it stands
you state you need to do something which is not possible in PostgreSQL.
Without context it is difficult to suggest alternatives.

Also, do not reply to people personally. These are public lists and
generally the people contributing to them either want to share the
information broadly or, as in this case, rely upon others to share in the
work. I have re-added pgsql-bugs on this reply.

​Also, it is customary to inline or bottom-post on these list - just like
Francisco and I both did in our replies to your initial bug reports.

David J.