CallableStatement: using named parameters to specify only certain parameter values
See original GitHub issue(ref: this Stack Overflow question)
Section 13.3.2 of the JDBC 4.2 specification says
Named parameters can be used to specify only the values that have no default value.
In CODE EXAMPLE 13-21, the procedure COMPLEX_PROC takes ten parameters, but only the first and fifth parameters, PARAM_1 and PARAM_5, are required.
CallableStatement cstmt = con.prepareCall(“{CALL COMPLEX_PROC(?, ?)}”; cstmt.setString(“PARAM_1”, “Price”); cstmt.setFloat(“PARAM_5”, 150.25);
I just tried this with 6.3.4.jre8-preview.jar and I couldn’t get it to work. It seemed that I had to provide a parameter placeholder for every possible parameter, ((?,?,?,?,?,?,?,?,?,?)
in the above example), and I didn’t see a way to specify DEFAULT
for a parameter that I would have otherwise simply omitted.
In other words, it seems like named parameter support for CallableStatement in mssql-jdbc is currently limited to allowing us to specify the parameters in any order, but not to “pick and choose” the parameters we actually supply.
Have I missed something?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top GitHub Comments
Hi @gordthompson , Thank you for creating the issue, I can confirm that this is a deficiency in the implementation. #547 is potentially related, we will address the issue once/when the PR is merged.
hi @kliakos Sorry to report that this issue is still in our backlog it didn’t make it to the top of the list in triage.