Handling database errors

You can control how database Vusers handle errors when you run a database Vuser script. By default, if an error occurs during script execution, the script execution is terminated. To change the default behavior, you can instruct the Vuser to continue when an error occurs. You can apply this behavior in different ways as described below.

Globally modify error handling

You can change the way that Vusers handle errors by issuing an LRD_ON_ERROR_CONTINUE or LRD_ON_ERROR_EXIT statement. By default, a Vuser aborts the script execution when it encounters any type of error, such as database or parameter related. To change the default behavior, insert the following line into your script:

 LRD_ON_ERROR_CONTINUE;

From this point on, the Vuser continues script execution, even when an error occurs.

You can also specify that the Vuser continue script execution when an error occurs only within a segment of the script. For example, the following code tells the Vuser to continue script execution even if an error occurs in the lrd_stmt or lrd_exec functions:

LRD_ON_ERROR_CONTINUE;
lrd_stmt(Csr1, "select..."...);
lrd_exec(...);
LRD_ON_ERROR_EXIT;

Use the LRD_ON_ERROR_CONTINUE statement with caution, as significant and severe errors may be missed.

Back to top

Locally modify error handling

You can set error handling for a specific function by modifying the severity level. Functions such as lrd_stmt and lrd_exec, which perform database operations, use severity levels. The severity level is indicated by the function's final parameter, miDBErrorSeverity. This parameter tells the Vuser whether or not to continue script execution when a database error occurs (error code 2009). The default, 0, indicates that the Vuser should end the script when an error occurs.

For example, if you reference a table that does not exist, the following database statement fails and the script execution terminates.

lrd_stmt(Csr1, "insert into EMP values ('Smith',301)\n", -1, 1 /*Deferred*/, 
        1 /*Dflt Ora Ver*/, 0);

To tell a Vuser to continue script execution, even when a database operation error occurs for that function, change the statement's severity parameter from 0 to 1.

lrd_stmt(Csr1, "insert into EMP values ('Smith',301)\n", -1, 1 /*Deferred*/, 
        1 /*Dflt Ora Ver*/, 1);

When the severity is set to 1 and a database error occurs, a warning is issued. Note that the severity level set for a particular function applies only to that function.

Back to top