How can I get value of inout parameter from PostgreSQL procedure call?
-
wrote on 28 Nov 2020, 23:03 last edited by
I have code like this
QString my_str = "call my_proc(null,null);"; QSqlQuery my_query(d); my_query.exec(my_str);
And it works, it calls the postgresql procedure
procedure my_proc(value int, return_value INOUT int);
But how can I get the value of the return_value parameter?
When I try to get the value fromquery.record
it seems the value is always 0.
So I guess I'm missing something important here.Is there an example of how to do this for Postgresql?
(note: it seems I can not call procedures with bind variables, else I would have tried that).
-
I have code like this
QString my_str = "call my_proc(null,null);"; QSqlQuery my_query(d); my_query.exec(my_str);
And it works, it calls the postgresql procedure
procedure my_proc(value int, return_value INOUT int);
But how can I get the value of the return_value parameter?
When I try to get the value fromquery.record
it seems the value is always 0.
So I guess I'm missing something important here.Is there an example of how to do this for Postgresql?
(note: it seems I can not call procedures with bind variables, else I would have tried that).
wrote on 29 Nov 2020, 08:52 last edited by JonB@OpenGL said in How can I get value of inout parameter from PostgreSQL procedure call?:
(note: it seems I can not call procedures with bind variables, else I would have tried that).
I don't know anything about PostgreSQL/procedure calls. But as far as I know you must bind to a variable to get an
OUT
parameter back. So show what you tried for theprepare
/bind()
? -
wrote on 30 Nov 2020, 21:37 last edited by
Prepare/bind does not work with postgres procedures, so I have to do it some other way. And I have no idea how.
-
Prepare/bind does not work with postgres procedures, so I have to do it some other way. And I have no idea how.
Hi,
@OpenGL said in How can I get value of inout parameter from PostgreSQL procedure call?:
Prepare/bind does not work with postgres procedures, so I have to do it some other way. And I have no idea how.
Can you provide more information about that ?
Do you have a simple example of procedure that can be tested ? -
Hi,
@OpenGL said in How can I get value of inout parameter from PostgreSQL procedure call?:
Prepare/bind does not work with postgres procedures, so I have to do it some other way. And I have no idea how.
Can you provide more information about that ?
Do you have a simple example of procedure that can be tested ?wrote on 2 Dec 2020, 22:11 last edited by@SGaist said in How can I get value of inout parameter from PostgreSQL procedure call?:
Hi,
@OpenGL said in How can I get value of inout parameter from PostgreSQL procedure call?:
Prepare/bind does not work with postgres procedures, so I have to do it some other way. And I have no idea how.
Can you provide more information about that ?
Do you have a simple example of procedure that can be tested ?Hello, sorry for late reply.
I had a discussion about it here https://forum.qt.io/topic/120460/minimal-sql-program-that-fails-what-is-wrong-with-it/2
An minimal example is included there with a procedure that failes to be prepared with the prepare command. -
@SGaist said in How can I get value of inout parameter from PostgreSQL procedure call?:
Hi,
@OpenGL said in How can I get value of inout parameter from PostgreSQL procedure call?:
Prepare/bind does not work with postgres procedures, so I have to do it some other way. And I have no idea how.
Can you provide more information about that ?
Do you have a simple example of procedure that can be tested ?Hello, sorry for late reply.
I had a discussion about it here https://forum.qt.io/topic/120460/minimal-sql-program-that-fails-what-is-wrong-with-it/2
An minimal example is included there with a procedure that failes to be prepared with the prepare command.wrote on 3 Dec 2020, 07:40 last edited by JonB 12 Mar 2020, 07:41@OpenGL
I'm not defending this other than as a nasty hack. But if what you say is true, and you are stuck looking for a workaround: you can pass input parameters by interpolating them literally into thecall()
statement, and you can receive output parameters by returning them via aSELECT
statement at the end of acall()
ed procedure. Assuming you get a result set back from thecall()
which the driver can retrieve.
2/6