The SQL Statement Advanced action executes SQL statements. It enables you to perform administrative tasks like cleaning a database after a test. It also allows you to get business-related metrics that you can monitor, for example the number of items in a work queue or the number of checkouts during the last minute.
The action produces an XML output that includes a status of the executed SQL statement as well as an optional section containing the results of the query. The query results are also stored in NeoLoad variables.
Information: In case of connection with Microsoft SQL Server 2005, you need to replace the Microsoft SQL Server 4.1 JDBC Driver with the Microsoft SQL Server 4.0 JDBC Driver by following this procedure.
When executing a query, be careful to specify the variable name, i.e "
" and not "
" is the column name as defined in the database. Invalid XML characters are removed, for example
would be renamed to
The query result values will be retrieved in the following variables:
An example of removing all lines of a table:
DELETE FROM table_name
An example of getting number of rows:
SELECT count(*) FROM table_name
In this example, since the query will return one row of one column, only the
variable will be created.
An example of SELECT with a custom driver:
SELECT * FROM records WHERE date='2014-11-11'
In this example, the following multi-valued variables will be created :
gives access to the id of the first row,
give access to the number of rows,
gives access to the date of a random row.