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

Returning Insert Resultset into Temporary Table

    XMLWordPrintable

Details

    • New Feature
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      Wanted to mark this as an improvement but that type wasn't available.

      For insert (and delete statements), the RETURNING clause can be used to return the records that were actually inserted into a table

      Currently however the returned resultset can only be returned to the caller. It cannot be stored into a temporary table, used as the values for a CTE, be used as subquery for a select statement, etc.
      i.e. we should be able to do this:

      CREATE TEMPORARY TABLE test(ikey INT NOT NULL AUTO_INCREMENT, ival INT, PRIMARY KEY(ikey));
       
      with inserted as(
      INSERT INTO test(ival)
      VALUES (10),(20),(30)
      RETURNING ikey, ival
      )
      

      .
      I believe both postgres and oracle support this syntax, and mssql has the OUTPUT clause.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jacobfw Jacob W
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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