oracle-r2dbc icon indicating copy to clipboard operation
oracle-r2dbc copied to clipboard

Question: DELETE command with RETURNING INTO

Open jenoforizs opened this issue 2 years ago • 3 comments

Quote from the readme: "Returning generated values is only supported for INSERT and UPDATE commands when a RETURNING INTO clause can be appended to the end of that command."

Is there any plan for implementing this feature for DELETE commands? To support such statement: "DELETE cars RETURNING listagg(distinct cars.registration_number, ',') INTO :registration_numbers;"

jenoforizs avatar May 25 '22 16:05 jenoforizs

Oracle R2DBC relies on the underlying Oracle JDBC driver to return generated values/keys, and Oracle JDBC only supports this for INSERT/UPDATE, not for DELETE. Currently, there's no plan to add support for DELETE.

However, it may be possible to return deleted values by registering an out parameter. Have you tried this approach?

I'm on break this week, but I might have some time to test it out on my own next week.

Michael-A-McMahon avatar May 27 '22 18:05 Michael-A-McMahon

Not quite a code example, but I do have test code that binds an out parameter with RETURNING INTO: https://github.com/oracle/oracle-r2dbc/blob/068cf0f4268d4d11789932eed1651010b0456327/src/test/java/oracle/r2dbc/impl/OracleStatementImplTest.java#L1454

The test code is executing an INSERT, but it I think it will be possible to do something similar for a DELETE.

Michael-A-McMahon avatar May 27 '22 18:05 Michael-A-McMahon

Michael, thank you for the reply, I really appreciate it. I'm going to check if I can use this solution.

jenoforizs avatar May 28 '22 10:05 jenoforizs

Hope things worked out. Please create a new issue if there's anything we need to add in Oracle R2DBC.

Michael-A-McMahon avatar Nov 10 '22 19:11 Michael-A-McMahon