You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
SQL> create sequence g;
SQL> recreate table t1(id int primary key using index t1_pk, x int);
SQL> recreate table t2(id int primary key using index t2_pk, x int);
SQL> commit;
SQL>
SQL> insert into t1 select gen_id(g,1), rand()*100 from rdb$types rows 10;
SQL> commit;
SQL>
SQL> alter sequence g restart with 0;
SQL> commit;
SQL>
SQL> insert into t2 select gen_id(g,1), rand()*100 from rdb$types rows 50;
SQL> commit;
SQL>
SQL> set term ^;
SQL> execute block returns(processed_rows int) as
CON> begin
CON> merge into t1 t using t2 s on http://t.id=s.id
CON> when MATCHED then update set t.x=t.x+s.x
CON> when NOT matched then insert values(http://s.id, s.x);
CON> processed_rows = row_count;
CON> suspend;
CON> end
CON> ^set term ;^
PROCESSED_ROWS
1
But:
SQL> select count(*) from t1;
COUNT
============
50 -- (10 rows updated and 40 rows added)
Tested on:
LI-V2.5.3.26744
LI-T3.0.0.31071
The text was updated successfully, but these errors were encountered:
Submitted by: @pavel-zotov
Votes: 1
SQL> create sequence g;
SQL> recreate table t1(id int primary key using index t1_pk, x int);
SQL> recreate table t2(id int primary key using index t2_pk, x int);
SQL> commit;
SQL>
SQL> insert into t1 select gen_id(g,1), rand()*100 from rdb$types rows 10;
SQL> commit;
SQL>
SQL> alter sequence g restart with 0;
SQL> commit;
SQL>
SQL> insert into t2 select gen_id(g,1), rand()*100 from rdb$types rows 50;
SQL> commit;
SQL>
SQL> set term ^;
SQL> execute block returns(processed_rows int) as
CON> begin
CON> merge into t1 t using t2 s on http://t.id=s.id
CON> when MATCHED then update set t.x=t.x+s.x
CON> when NOT matched then insert values(http://s.id, s.x);
CON> processed_rows = row_count;
CON> suspend;
CON> end
CON> ^set term ;^
PROCESSED_ROWS
But:
SQL> select count(*) from t1;
============
50 -- (10 rows updated and 40 rows added)
Tested on:
LI-V2.5.3.26744
LI-T3.0.0.31071
The text was updated successfully, but these errors were encountered: