Details
-
New Feature
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Duplicate
-
None
-
None
Description
MariaDB supports the RETURNING clause for INSERT, UPDATE and DELETE.
However, it is not possible to store the result of the RETURNING columns into variables for use in stored routines (as of MariaDB 11.7.2). This requires significant workarounds for example in the following use case:
INSERT INTO my_table (...) |
VALUES (...) |
ON DUPLICATE KEY UPDATE ...; |
Now I want to capture the inserted or updated id column, but LAST_INSERT_ID() doesn't work when the row was updated and instead returns NULL.
With
RETURNING id INTO my_variable |
it would be very easy to solve this.
Alternatively, LAST_INSERT_ID() should return the updated row id, but then this only works for an AUTO_INCREMENT column, which is not always used and therefore only partially solves the issue.
PostgreSQL, SQL Server and Oracle all support RETURNING .. INTO (or OUTPUT INTO) clause.
I would kindly request for RETURNING .. INTO to be implemented! 🙏
Attachments
Issue Links
- duplicates
-
MDEV-25860 Implement INSERT INTO <TABLE> VALUES <VALUES> RETURNING <FIELDS> INTO <HOST_VARIABLES>
-
- Open
-
-
MDEV-36242 INSERT ... RETURNING <column> INTO <variable>
-
- Closed
-