SAP Knowledge Base Article - Preview

3074720 - MERGE statement may return a wrong rowcount when there is no affected row - SAP ASE

Symptom

  • Even though MERGE statement does not perform any action, it may incorrectly return a rowcount higher than 0.
  • The following MERGE statement does not perform any action and "1 row affected" is displayed, but "0 rows affected" should be displayed.

create table t1 (col1 int)
go
(1 row affected)
create table t2 (col1 int)

go
(1 row affected)
insert into t1 values (1)
go
(1 row affected)
insert into t2 values (1)
go
(1 row affected)

merge into t2 b using ( select col1 from t1 ) c on ( b.col1 = c.col1 )
when matched and c.col1 > b.col1 then update set b.col1 = c.col1 + 1
when not matched then insert ( col1 ) values ( c.col1 )
go
(1 row affected)


Read more...

Environment

  • SAP Adaptive Server Enterprise (ASE) 15.7
  • SAP Adaptive Server Enterprise (ASE) 16.0

Product

SAP Adaptive Server Enterprise 15.7 ; SAP Adaptive Server Enterprise 16.0

Keywords

CR814782, 814782, #814782, MERGE, "rows affected", incorrect, wrong, bigger, larger, , KBA , BC-SYB-ASE , Sybase ASE Database Platform (non Business Suite) , Bug Filed

About this page

This is a preview of a SAP Knowledge Base Article. Click more to access the full version on SAP for Me (Login required).

Search for additional results

Visit SAP Support Portal's SAP Notes and KBA Search.