Skip to content

Calling stored procedure directly #547

Closed
AfsanehR-zz wants to merge 51 commits intomicrosoft:mainfrom
AfsanehR-zz:storedProcedure
Closed

Calling stored procedure directly #547
AfsanehR-zz wants to merge 51 commits intomicrosoft:mainfrom
AfsanehR-zz:storedProcedure

Conversation

@AfsanehR-zz
Copy link
Copy Markdown
Contributor

@AfsanehR-zz AfsanehR-zz commented Nov 8, 2017

calling stored procedure directly instead of wrapping it around exec sp_executesql.

Not to be merged yet. Opening this pull request for discussion and improvement.

Notice that this still does not have the push for avoiding the metadata lookup with named params. Will be adding that soon to the same pr in another commit.

xiangyushawn and others added 30 commits August 8, 2017 17:14
…oredProcedure

# Conflicts:
#	src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java
@AfsanehR-zz
Copy link
Copy Markdown
Contributor Author

I also added the fix for removing metadata lookup for named parameters. This will break the existing applications that use a mix of named and index parameters.
For example for a proc like:

CREATE PROCEDURE proc (
    @par1 INT = NULL
) AS
BEGIN
	insert into tempTable values (@par1)
END

If we need to use named parameters to get the output parameters, we need to register the parameter with name values:

callableStatement.registerOutParameter("@par1", java.sql.Types.INTEGER);
callableStatement.execute();

and then call:
callableStatement.getObject("@par1");

Registering output parameter with name and using indexes to retrieve them, however, still works.

@AfsanehR-zz AfsanehR-zz mentioned this pull request Nov 24, 2017
4 tasks
Comment thread src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java Outdated
Comment thread src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
Comment thread src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java Outdated
@cheenamalhotra cheenamalhotra added the Work in Progress The pull request is a work in progress label Jul 27, 2018
cheenamalhotra and others added 11 commits February 4, 2019 15:34
# Conflicts:
#	src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
#	src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java
#	src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
#	src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java
#	src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java
#	src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java
#	src/main/java/com/microsoft/sqlserver/jdbc/dtv.java
#	src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/CallableStatementTest.java
@praskutti
Copy link
Copy Markdown

Hello mssql-jdbc team, can you please let me know when this will be merged and released?

@ulvii
Copy link
Copy Markdown
Contributor

ulvii commented Nov 2, 2020

Hi @praskutti ,
The PR is incomplete and requires quite some changes to merge it. It is in our backlog to address them, but there is no timeline currently.

@praskutti
Copy link
Copy Markdown

Hi @praskutti ,
The PR is incomplete and requires quite some changes to merge it. It is in our backlog to address them, but there is no timeline currently.

Thanks @ulvii . I coded a usable workaround for our requirement (to create a generic method for SQL Server proc calls that would avoid extra metadata lookups). I thought this PR would solve it, but because it will take time to release, we will roll with our method. I will post the code-sample soon.

@lilgreenbird lilgreenbird removed the Work in Progress The pull request is a work in progress label Sep 22, 2021
@Jeffery-Wasty
Copy link
Copy Markdown
Contributor

This is still being worked on #2154.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed/Merged PRs

Development

Successfully merging this pull request may close these issues.