How to write multiple SQLRPGLE records into a printer file

195 pts.
Tags:
AS/400
AS/400 output files
SQL commands
SQLRPGLE
C/EXEC SQL C+ SELECT DISTINCT(CTP),COUNT(*) INTO :$Ctp,:#Ctotl FROM CUSTPF C+ GROUP BY CTP C/END-EXEC CTP is CustomerType in Customer File. 

Here actually I am getting 3 records as output. But I don't know how to write those 3 records into a printer file. Can anybody explain me how to write the output of a select query if it gives more than a row?


Software/Hardware used:
AS400

Answer Wiki

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

Discuss This Question: 4  Replies

 
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
  • philpl1jb
    In general terms you want to treat the results of any sql statement that creates multiple rows of results as a cursor. The SQL commands you will need are DECLARE CURSOR OPEN CURSOR FETCH NEXT FROM CURSOR into xxx,yyy with a loop to continue fetching until the sql eof heere is a site with a great discussion/example http://www.bmeyers.net/faqs/frequently-asked-questions/75-embedded-sql-using-a-cursor Phil
    51,355 pointsBadges:
    report
  • TomLiotta
    There's no choice if there are multiple rows to be processed for printing -- they will have to be FETCHed through a cursor. There's no other way to handle individual rows from a multi-row result set. It's only when a single row (or column) is returned from a SELECT that a cursor isn't required. Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    Tom Did you just agree with me? When do the winged monkeys swoop down? Phil
    51,355 pointsBadges:
    report
  • TomLiotta
    @Phil: Yep. I started to write "Don't be so gentle; there's no choice..." :-) , but simple confirmation to show a consensus seemed best. Tom
    125,585 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