Wednesday, 11 June 2014

How to execute a DB2 script with begin atomic

How to execute a DB2 script with begin atomic

Example1:

begin atomic
declare x char;
set x=(select nome from db2inst1.x0 where nome='a');
insert into db2inst1.x0  (nome) values (x);
end@

Example2:
begin atomic
insert into db2inst1.x0 (nome) values ('cd');
insert into db2inst1.x1  (cod) values (select identity_val_local() from sysibm.sysdummy1);
end@

To execute theses scripts via command line:
db2 -td@ -vf <scriptname>

No comments:

Post a Comment