PlugIns JdbcSlim UserGuide 7UsingSqlInScriptsAndScenarios
Contents:
This page calls the SQL Command fixture in a scenario
Results returned are assigned to symbols and can be used in future queries or fixtures.
Assign results from a query to symbols
| SQLCommand | TestDatabase | select Id, Name from TestData where ID = '%X%' |
| X | ID? | NAME? |
| 2 | <= 3 | $Name2= |
| 4 | >= 4 | $Name4= |
| 2 | 1<_ <3 | Ben |
| 3 | $Id3= |
| script | |||
| check | echo | $Name2 | Ben |
| check | echo | $Name4 | Till |
| check | echo | $Id3 | 3 |
| Define Properties | DefinitionOne |
| key | value |
| cmd | select * from Elements where ID = '%X%' |
| .include | TestDatabase |
Scenario with two execute statements returning the result in symbols
| Scenario | TheId | id | isNamed | name | andHasPhone | phone |
| execute | select * from TestData where ID = '@id' | |||||
| show | success | |||||
| show | rawResult | |||||
| show | resultSheet | |||||
| $name= | getColumnValueByName | Name | ||||
| # | ||||||
| execute | select * from TestData where ID = '@id' | |||||
| show | success | |||||
| show | rawResult | |||||
| show | resultSheet | |||||
| $phone= | getColumnValueByName | Phone | ||||
Start the test
Open a connection
| Script | SQLCommand | DefinitionOne |
| openConnection | ||
Call the scenario
| TheIdIsNamedAndHasPhone | ||
| id | name? | phone? |
| 2 | $Name2= | >0 |
| 4 | $Name44= | >100 |
| 3 | Tom | $Phone3= |
| 2 | =~/Be/ | >5 |
| script | |||
| check | echo | $Name2 | Ben |
| check | echo | $Name44 | Till |
| check | echo | $Phone3 | 4567890 |
Close the connection
| Script |
| closeConnection |