How can I get value of inout parameter from PostgreSQL procedure call?
-
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).
-
@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()
? -
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 ? -
@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. -
@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.