background image
<< Simple Correlated Queries | To correlate the queries >>
<< Simple Correlated Queries | To correlate the queries >>

simple correlated query

Database Vuser Scripts · Correlating Database Statements
Creating Vuser Scripts
Chapter 10, page 177
The script below illustrates a simple correlated query. The user performed a query
to retrieve John's ID of 777. A second query on a different table, retrieved the salary
of the employee with the above ID. The user waited for the results of the first query,
before performing the second query.
You can perform an identical operation by nesting the queries. However, the
database statements become complex and difficult to understand.
lrd_stmt(Csr1, "select id from employees where name='John'", ...);
lrd_bind_col(Csr1,1,&ID_D1,...);
lrd_exec(Csr1, ...);
lrd_fetch(Csr1, 1, ...);
lrd_stmt(Csr1, "select salary from payment where id= '777'",...);
lrd_exec(Csr1, ...);
lr_think_time(17);
lrd_stmt(Csr1, "select salary from sal_j1 where id = (select id from "
"emp_j1 where name='John')\n", -1, 1, 1, 0);
lrd_bind_col(Csr1, 1, &SALARY_D11, 0, 0);
lrd_exec(Csr1, 0, 0, 0, 0, 1);
lrd_fetch(Csr1, -1, 1, 0, PrintRow7, 0);