﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33741	Transaction Management inside PROCEDURE	Victor Vieux	nobody	"Hello,

I have a PROCEDURE that uses [Transaction Management](https://www.postgresql.org/docs/current/plpgsql-transactions.html) from postgres (meaning there are COMMITs inside the procedure itself)
It runs fine in postgres, but when trying to invoke it from django either via 

{{{
with connection.cursor() as c:
    c.execute(...)
}}}

or

{{{
cursor.callproc
}}}

I get the following error:

{{{
django.db.utils.InternalError: invalid transaction termination
CONTEXT:  PL/pgSQL function xxx() line xx at COMMIT
}}}

I think that's because when executing raw queries with execute, they are run inside a transaction?
Is there a way to bypass this?

Thanks.
"	Bug	new	Database layer (models, ORM)	4.0	Normal		database procedure transaction		Unreviewed	0	0	0	0	0	0
