PlugIns.JdbcSlim.UserGuide.4TheMappingBetweenTestDataAndCommands.InsertUpdateDelete.CommandChain

PlugIns JdbcSlim UserGuide 4TheMappingBetweenTestDataAndCommands InsertUpdateDelete



Some jdbc driver support multiple commands separated with ; in a single execution.

To avoid side effects we execute the test in a transaction

Script SQLCommand TransactionDatabase
open Connection
execute begin transaction


Two updates in one command


Define Properties CommandChain
key value
.include TransactionDatabase

There are 3 matching names and one matching ID. Count should be 3, 1 but H2 reports only the first update 3
SQLCommand CommandChain update TestData set City='%NewCITY%' where NAME like'%Name%';update TestData set City='%NewCITY%' where ID ='%ID%'
ID Name NewCITY Count? Count2?
3 B% *Madrid* 3 1


Changing the order of the commands we get 1 expected is 1, 3
SQLCommand CommandChain update TestData set City='%NewCITY%' where ID ='%ID%';update TestData set City='%NewCITY%' where NAME like'%Name%'
ID Name NewCITY Count? Count2?
4 B% **Sydney** 1 3


Verify all updates

SQLCommand CommandChain select * from TestData Query
ID Name Phone City Profession
1 Bill 12345 **Sydney** Doctor
2 Ben 6789 **Sydney** Artist
3 Tom 4567890 *Madrid* Milkman
4 Till 332211 **Sydney** Senator
5 Sarah 999999 Paris Hero
6 James 5432 London Butler
7 Bert 432 **Sydney** President
8 Kim 1 New York Banker


Rollback the change to not impact future tests


Script SQLCommand TransactionDatabase
open Connection
execute rollback
close Connection

Check that the rollback worked

SQLCommand StartupDatabase select * from TestData Query
ID Name Phone City Profession
1 Bill 12345 Berlin Doctor
2 Ben 6789 Denver Artist
3 Tom 4567890 Seoul Milkman
4 Till 332211 Berlin Senator
5 Sarah 999999 Paris Hero
6 James 5432 London Butler
7 Bert 432 Washington President
8 Kim 1 New York Banker