SQL cursor question

895 pts.
Tags:
RPGLE
SQL
SQL Cursors
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.   

Answer Wiki

Thanks. We'll let you know when a new response is added.

Seems like it would look something like this.

fetch next

If FldA <> 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

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Littlepd
    Post your SQL statement and I'll show you how to write a UNION query that'll do subtotals.
    1,130 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following