| SET VAR vCustid TEXT
|
| DECLARE c1 CURSOR FOR SELECT DISTINCT custid +
|
| FROM transmaster
|
| DECLARE c2 CURSOR FOR SELECT transid, empid, +
|
| invoicetotal, transdate FROM transmaster +
|
| WHERE custid = .vCustid
|
| OPEN c1
|
| FETCH c1 INTO vCustid Ind1
|
| WHILE SQLCODE <> 100 THEN
|
|
|
| -- This is the break header position,
|
| -- the first customer ID is retrieved.
|
| -- Cursor c2 fetches all transaction rows for
|
| -- that customer.
|
|
|
| OPEN c2 RESET
|
| FETCH c2 INTO vTransid vind1, vEmpid vind2, +
|
| vInvoiceTotal vind3, vTransDate vind4
|
| WHILE SQLCODE <> 100 THEN
|
| -- The detail rows are processed here.
|
| FETCH c2 INTO vTransid vind1, vEmpid vind2,
|
| vInvoiceTotal vind3, vTransDate vind4
|
| ENDWHILE
|
|
|
| -- The break footer position is here,
|
| -- right before the next customer row is fetched.
|
|
|
| FETCH c1 INTO .vCustid
|
| ENDWHILE
|