SAP Knowledge Base Article - Preview

3074720 - MERGE 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 bigger than 0.
  • The following MERGE statement does not perform any action and "1 row affected" is displayed, but "0 rows affected" should be displayed.

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


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" , 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 ONE Support launchpad (Login required).

Search for additional results

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