background image
<< Using Correlated Query Functions | Decide which value to correlate >>
<< Using Correlated Query Functions | Decide which value to correlate >>

About Correlating Database Statements

Creating Vuser Scripts
Chapter 10, page 162
Database Vuser Scripts Correlating Database Statements
About Correlating Database Statements
There are two main reasons for linking (correlating) database queries:
To simplify or optimize your code
For example, if you perform a series of dependent queries one after another, your
code may become very long. In order to reduce the size of the code, you can nest
the queries, but then you lose preciseness and the code becomes complex and
difficult to understand. Correlating the queries allows you to link queries without
To successfully run the script
For example, suppose you record the process of opening a new bank account.
Each new account is assigned a unique number which is unknown to the user and
this account number is inserted into a table with a unique key constraint during
recording. If you try to run the script as recorded, it will try to create an account
with the recorded number, rather than a new unique number. You will get a
database error because the account number already exists.
If you encounter an error when running your script, examine the script at the point
where the error occurred. In many cases, a correlated query will solve the problem,
by allowing you to use the results of one statement as input to another.