jdbi icon indicating copy to clipboard operation
jdbi copied to clipboard

Does jdbi support in/out parameter in procedure(for Oracle)?

Open joshua-jin opened this issue 6 years ago • 5 comments

I have a procedure in Oracle like this:

procedure foo(v1 in number, v2 in char, v3 in out number );

and my java code is:

handle.bind("v1", 42)
           .bind("v2", "Y")
           .bind("v3", 99)
           .registerOutParameter("v3", Types.INTEGER)

But when I get result for "v3", the value is always 0, and I follow the source code(not very carefully), I think jdbi will overwrite the parameter, when bind and registerOutParameter use the same name.

So is there any solution for invoking a procedure, when procedure has a paremeter is both in and out ?

joshua-jin avatar Sep 17 '19 02:09 joshua-jin

I think you're right, this doesn't work right. Figuring out what's wrong is hampered by both the h2 and pg-jdbc drivers not fully supporting named callable parameters... I started hacking here https://github.com/jdbi/jdbi/tree/call-inout but no fix yet.

stevenschlansker avatar Sep 21 '19 17:09 stevenschlansker

@stevenschlansker Maybe I can fork your branch and try to fix this bug?

joshua-jin avatar Sep 29 '19 07:09 joshua-jin

Please feel free. I feel like it's close, but got distracted by other issues. I'll look more myself soon too.

stevenschlansker avatar Sep 29 '19 16:09 stevenschlansker

@joshua-jin This generally happenes when you use select statement in stored procedure on db side to return a value, Try replacing your select with return statement if not already ??

manish7-thakur avatar Jan 27 '20 07:01 manish7-thakur

@joshua-jin, changing the order of binds worked for me. Have a look here

schrieveslaach avatar Sep 21 '21 16:09 schrieveslaach