WesternGun
WesternGun

Reputation: 12787

Spring R2DBC + SQL Server: procedures query

I am required to execute a stored procedure in a SQL server to fetch some data, and since I will later save the data into a Mongo and this one is with ReactiveMongoTemplate and so on, I introduced Spring R2DBC.

    implementation("org.springframework.data:spring-data-r2dbc:1.0.0.RELEASE")
    implementation("io.r2dbc:r2dbc-mssql:0.8.1.RELEASE")

I see that I can do SELECT and INSERT and so on with R2DBC, but is it possible to EXEC prod_name? I tried it and it hangs forever and then the test terminates, without success but neither failure. The last line of log is:

io.r2dbc.mssql.QUERY - Executing query: EXEC "SCHEMA"."MY_PROCEDURE" 

The code is like:

    public Flux<Coupon> selectWithProcedure() {
        return databaseClient
                .execute("EXEC \"SCHEMA\".\"MY_PROCEDURE\" ")
                .as(Coupon.class)
                .fetch().all()
                .doOnNext(coupon -> {
                    coupon.setCouponStatusRefFromId(coupon.getCouponStatusRefId());
                });
    }

And it seems that no data is retrieved.

If I test some other methods with simple queries like SELECT... it works. But the problem is, DBAs do not allow my app to read table data, instead, they create a procedure for me. If this query is not possible, I must go with traditional JPA way and going reactive at Mongo side has lost its sense.

Upvotes: 1

Views: 3062

Answers (1)

WesternGun
WesternGun

Reputation: 12787

Well. I just saw this:

https://github.com/r2dbc/r2dbc-mssql, version 0.8.1:

Next steps:

  • Execution of stored procedures
  • Add support for TVP and UDTs

And:

https://r2dbc.io/2019/05/13/r2dbc-0-8-milestone-8-released

We already have a few tickets lined up for the next milestone, and we know that they will require further SPI modifications:

  • Support for Auto-Commit
  • Connection Validation
  • Support for Stored Procedures

Upvotes: 1

Related Questions