PlugIns.JdbcSlim.UserGuide.4TheMappingBetweenTestDataAndCommands.ReadableLongCommands.PreFormattedSql

PlugIns JdbcSlim UserGuide 4TheMappingBetweenTestDataAndCommands ReadableLongCommands



When SQL gets more complex it can be easier to maintain in the wiki if it is preformatted instead of in a single line.

Inline

In Properties

We can use preformatted SQL in properties.

Define Properties Preformatted
key value
.include TestDatabase
cmd
 
select ID from TestData
 where Name ='%Name%' 
 
 and City ='%City%' 

SQLCommand Preformatted
Name City ID?
James London 6

In SQLCommand

We can also use preformatted SQL in a SQLCommand table's constructor.

SQLCommand Preformatted
 select ID from TestData
    where Name ='%Name%'

and City ='%City%' 
Name City ID?
James London 6

Using a variable

But using preformatted SQL inside a table can make wiki pages hard to edit.
So we can also use variables to contain the SQL statement.
Which will leave the wiki's source code much cleaner.

variable defined: SQL={{{ select ID from TestData where Name ='%Name%' and City ='%City%' }}}
Define Properties Preformatted2
key value
.include TestDatabase
cmd
select ID
 from TestData
 where Name ='%Name%'
 and City ='%City%'

SQLCommand Preformatted2
Name City ID?
James London 6

SQLCommand Preformatted2
select ID
 from TestData
 where Name ='%Name%'
 and City ='%City%'
Name City ID?
James London 6