Closed Andrey7700 closed 2 years ago
The handling of stored procedures is very database-specific and I believe that Postgres doesn't even support INOUT parameters.
For any OUT values you should try using into(...)
instead of use(...)
.
The handling of stored procedures is very database-specific and I believe that Postgres doesn't even support INOUT parameters. For any OUT values you should try using
into(...)
instead ofuse(...)
.
Postgres definitely supports it, I've tested via pgAdmin4, these params were updated.
I don't think in/out parameters are supported by any backend other than Oracle. We discussed this in #366 many years ago and I see that I was in favour of adding a separate inout()
and implementing support for it for all, or at least several, backends, instead of allowing to modify the variables passed to use()
. I think it's still probably a better idea, but this remains rather academic unless somebody plans to actually work on it.
Thank you guys for your response! Finally I managed to get proper result, with following steps:
dummy values need to be passed in procedure call instead of variables (11 and null in my case), and into specifier to be used for both variables.
(sql.prepare << "call cbs_owner.test_proc(:par1,:par2,:par3,:par4,:par5,:par6,:par7,:par8,:par9,:par10,11,null)", use(par1, "par1"), use(par2, "par2"),use(par3, "par3"),use(par4, "par4"), use(par5, "par5"),use(par6, "par6"), use(par7, "par7"),use(par8, "par8"), use(par9, "par9"),use(par10, "par10"),
into(io_ret_code ), into(io_ret_msg ));
std::string postgresql_statement_backend::rewrite_for_procedure_call(
std::string const & query)
{
// std::string newQuery("");
// newQuery += query;
return query;
}
Postgres procedure signature:
in test cpp file, I have this code:
also, in soci/src/backends/postgresql/statement.cpp,
before this call is fired:
After C++ call, in Postgres related table is updated based on test_proc logic, but variables
io_ret_code
andio_ret_msg
are not changed. Not sure how I can make these parameters return value.