Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlCall calculates the number of input parameters wrong [DATAJDBC-7] #264

Closed
spring-projects-issues opened this issue Apr 26, 2011 · 4 comments
Assignees
Labels
in: core Issues in core support status: declined A suggestion or change that we don't feel we should currently apply type: bug A general bug

Comments

@spring-projects-issues
Copy link

Catwalker Liu opened DATAJDBC-7 and commented

SqlCall line 132-152 composing sql call string. The number of input parameters represented by "?" is calculated wrong if backend is function (vs. procedure) and SqlReturnResultSet is used.

MyStoredProcedure extends StoredProcedure ...

super(...)
declareParameter(new SqlReturnResultSet("rs", new MyMapper()));
declareParameter(new SqlParameter("FIRST_NM", Types.VARCHAR));


No further details from DATAJDBC-7

@spring-projects-issues
Copy link
Author

Thomas Risberg commented

Does your code call setFunction(true)?

http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/jdbc/object/SqlCall.html#setFunction%28boolean%29

That's necessary if you are calling a function.

Also, anything that is part if Spring Framework should go in as a Spring JIRA issue (https://jira.springsource.org/browse/SPR). I'll move this later if necessary.

-Thomas

@spring-projects-issues
Copy link
Author

Catwalker Liu commented

Yes I did call setFunction(true) after these declareParameter(...)

In code line 132-152 parameterCount is set to -1 for function, but the code also exclude SqlReturnResultSet effectively. (parameterCount++ is inside of instanceof check).
This is double de-count for (function+SqlReturnResultSet) case.

@spring-projects-issues
Copy link
Author

Thomas Risberg commented

Yes, that is correct - SqlReturnResultSet is used with SQL Server and Sybase that return resultsets from regular stored procedure calls. Didn't think of that initially, and since you are calling a function it's not the right parameter type to use. Depending on the database your parameter would look a bit different. If you are using Oracle try the following:

declareParameter(new SqlOutParameter("rs", oracle.jdbc.OracleTypes.CURSOR, new MyMapper()));

and for Postgres you would use:

declareParameter(new SqlOutParameter("rs", Types.OTHER, new MyMapper()));

Let me know how this works out or if you are using some other database.

-Thomas

@spring-projects-issues
Copy link
Author

Thomas Risberg commented

I'm closing this issue. If you are still having problems you can open a new Spring Framework issue (https://jira.springsource.org/browse/SPR).

-Thomas

@spring-projects-issues spring-projects-issues added type: bug A general bug status: declined A suggestion or change that we don't feel we should currently apply in: core Issues in core support labels Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core support status: declined A suggestion or change that we don't feel we should currently apply type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants