Is it possible to embedded execute() in a custom function for CALL statement? #1534
Unanswered
jimmymcheung
asked this question in
Q&A
Replies: 1 comment 1 reply
-
If the function called does transaction control, it cannot run in a transaction. Psycopg, by default, starts a transaction automatically. If you want to change this behaviour, you should use an autocommit connection. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I tried to execute a procedure by cursor.execute() inside a custom function, but it was not succeeded. Running other kind of statement do works, running exact same script that the custom function does in a python console also works. I have go through a number of discussion and googled, but doesn't seem to fix.
Below is an example code:
and the procedure (to be called by `pg_procedue_one(IN id text):
If run from above python script, a commit error will be raised with following msg
CONTEXT: PL/pgSQL function pg_procedue_one(text) line 15 at COMMIT
. However, if running same code in this function (see below), it will be successfully inserted to the database.SELECT
from the database will show the entry '12994' with the current date.Beta Was this translation helpful? Give feedback.
All reactions