PlugIns.JdbcSlim.UserGuide.7UsingSqlInScriptsAndScenarios

PlugIns JdbcSlim UserGuide



Contents:


This page demonstrates the SQL Command fixture in a script and a scenario.
The scenario uses two queries.
It also shows additional methods available to analyse the returned data.

Calling the SQLCommand directly in a Script


Define Properties ScriptDefinition
key value
.include TestDatabase
cmd select * from TestData

Script SQLCommand ScriptDefinition
openConnection
execute
show success
show rawResult
show resultSheet
$RSOne= resultSheet
closeConnection

Calling the SQLCommand directly in a Script (simplified syntax)

When just executing a single SQL statement (or when connection re-use is enabled) one can ommit the the 'openConnection' and 'closeConnection' commands.
The 'run' command will turn red if the query failes (similar to a call to 'success' after 'execute')

Script SQLCommand ScriptDefinition
run select * from TestData
check getRowCount >0
show getColumnValueByName NAME
show getRow 1
show rawResult
show resultSheet
$RSOne= resultSheet

Script SQLCommand ScriptDefinition
run select * from TestData where id='-1'
check getRowCount 0

Using SQLCommand in a scenario


The Scenario with two execute statements


Readable SQL can also be used in a script, to make it easier to edit the wiki page with more complex SQL.

variable defined: SQL= {{{ select * from TestData where ID = '@id' }}}

Scenario The Id id isNamed name andHasPhone phone
execute select Name from TestData where ID = '@id'
show success
show rawResult
show resultSheet
check getColumnValueByName NAME @name
# use preformatted SQL
execute
select *
from TestData
where ID = '@id'
show success
show rawResult
show resultSheet
check getColumnValueByName Phone @phone



Start the test

Open a connection

Script SQLCommand ScriptDefinition
openConnection


Call the scenario in a Decision Table


The Id Is Named And Has Phone
id name phone
2 Ben >0
4 Till >100
3 Tom >10
2 =~/Be/ >5

Call the scenario in a Script Table


script
TheId 5 IsNamed Sarah AndHasPhone 999999


Close the connection

Script
closeConnection