background image
<< simple correlated query | Correlating Queries with Binding— >>
<< simple correlated query | Correlating Queries with Binding— >>

To correlate the queries

Creating Vuser Scripts
Chapter 10, page 178
Database Vuser Scripts · Correlating Database Statements
In
To correlate the queries, you save the value of a query with the lrd_save_col
function. In this example, lrd_save_col saves the value of the first column and first
row in the returned table (John's ID of 777) and assigns it to a newly defined
parameter,
emp_id
. This value is used in the second query.
lrd_stmt(Csr1, "select id from employees where name='John'", ...);
lrd_bind_col(Csr1,1,&ID_D1,...);
lrd_exec(Csr1, ...);
lrd_save_col(Csr1, 1, 1, 0, "emp_id");
lrd_fetch(Csr1, 1, ...);
lrd_stmt(Csr1,"select salary from payment where id ='<emp_id>'",...);
lrd_exec(Csr1, ...);