Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-36778

Support RETURNING .. INTO

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • N/A
    • 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

          Activity

            People

              Unassigned Unassigned
              louis77 Louis Brauer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.