AS400

420 pts.
Tags:
AS400 RPGLE
If i have a pf (pf1) R Rec account 10p00 name 10a dept 1a salary 5p00 k account After Updating, I given dept- A, S, D different account, different salary. NOW I AM TRYING TO ADD SALARY ON DEPT WISE {FOR EXAMPLE- IN SQL, SELECT SUM(SALARY) FROM PF1 WHERE DEPT='A'} BUT I AM TRYING IN RPGLE .. IT IS POSSIBLE TO ADD SALARY ON DEPT BASIS ? HOW ?

Software/Hardware used:
SOFTWARE

Answer Wiki

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

You can use the same SQL statement in your RPG program.

Discuss This Question: 6  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
    If you create a logical file on DEPT and use that in your program, then this sould be rather simple.
    51,365 pointsBadges:
    report
  • TomLiotta
    As CharlieBrowne said, you can use pretty much the same SQL in RPG. Here's a trivial example:   H Debug D mySUM s 10 2 /free exec sql SELECT SUM(SALARY) INTO :mySUM FROM PF1 WHERE DEPT='A'; dump ; return ; /end-free   The DEBUG keyword is just for testing, and the DUMP statement is also for testing.   Or are you needing to know how it would be done using native I/O? If so, please post the code you've been trying to create.   Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    Sorry about the code formatting. I'm not sure why the {code} function is included with the editor since it doesn't do anything useful.   Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    and this is homework.
    51,365 pointsBadges:
    report
  • anupsshelke
    *************** Beginning of data *********************************************** flab25     if   e           k disk                                                c                   dow       *in03='0'                                           c                   read      rec                                    03           c                   move      *blanks       dept1             1 0                 c                   z-add     0             sala2             6 0                 c/exec sql                                                                        c+ SELECT dept, sum(salary) into :dept1, :sala2 FROM lab22 GROUP BY dept          c/end-exec                                                                        c     dept1         dsply                                                         c     sala2         dsply                                                         c                   enddo                                                         c                   seton                                        lr         ******************************************************************************************* its giving me error that- SQL Pre-compiler failed....                              
    420 pointsBadges:
    report
  • TomLiotta
    giving me error   You need to show us the error. "SQL Pre-compiler failed" is not the error; it's only a message telling that the pre-compiler couldn't finish. You need to look at the pre-compiler output to see the error (and show it to us).   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