Issue Details (XML | Word | Printable)

Key: CORE-3020
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Adriano dos Santos Fernandes
Reporter: Pavel Zotov
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Firebird Core

add clause RETURNING ... INTO ... to MERGE statement

Created: 27/May/10 02:54 PM   Updated: 28/Sep/15 01:53 PM
Component/s: None
Affects Version/s: 2.5 RC2
Fix Version/s: 3.0 Alpha 1

Issue Links:
Relate
 
Replace
 


 Description  « Hide
It will be nice if we can do something like this:

  merge into fbl_row t
  using (select :vdid vdid, :vpid vpid, :vqty vqty, :vcost vcost from rdb$database ) s
  on (t.did=s.vdid and t.pid=s.vpid)
  when matched then
      update set pqty = pqty + s.vqty, rcnt = rcnt+1
  when NOT matched then insert (id, did, pid, pqty, pcost)
      values(gen_id(gen_test2,1), s.vdid, s.vpid, s.vqty, s.vcost);
  returning id
  into :vrow;

As far as I understand current version of FB does not support it ? (http://firebirdsql.org/rlsnotesh/rlsnotes210.html#rnfb210-merge)

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Pavel Zotov added a comment - 06/Mar/14 12:04 PM - edited
Adriano,

is it possible to add RETURNING clause not only to INSERT statement (i.e in the "when NOT matched" branch) but also to UPDATE one (into "when MATCHED") ?

Adriano dos Santos Fernandes added a comment - 06/Mar/14 12:08 PM
RETURNING is not for INSERT only, it's used once for both.