895 pts.
 SQL cursor question
hi,

i've SQLRPGLe program in which i'm writing a cursor to select all records, order them by a field A (suppose employee number). And once all the rows fetched for an employee and printed, print the count at the bottom. Repeat this for all the subsequent employees....

i'm not sure how to handle the print count part...i.e. in SQL how to differentiate when the new employee number begins..

i'm not willing to use ReadE or chain as the SQL query mentioned above has joins and selections date range....for which i think SQl will be faster and simple.

Thanks,

Nutan.   



Software/Hardware used:
ASKED: August 20, 2009  2:24 PM
UPDATED: August 20, 2009  3:30 PM

Answer Wiki:
Seems like it would look something like this. fetch next If FldA &lt;&gt; holdFldA // break on field change holdFldA = FldA Write TotLin Eval TotCnt = *zero endif Eval TotCnt += 1 ... Phil Sorry the editor is having more fun with me <> above should be the symbols for not equal to Phil
Last Wiki Answer Submitted:  August 20, 2009  2:44 pm  by  philpl1jb   44,200 pts.
All Answer Wiki Contributors:  philpl1jb   44,200 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Post your SQL statement and I’ll show you how to write a UNION query that’ll do subtotals.

 1,130 pts.