Cursor

510 pts.
Tags:
AS 400
SQLRPGLE
Hi, I have posted my SQLRPGLE program, output is not showing down,what mistake i did in my program,please correct it,

FMA01F     IF   E           K DISK   

FMA01FTES  IF A E    K DISK   RENAME(RMA01F:REMA01F) PREFIX(P_)   D COMNO           S              3  0       

D SHPNO           S              5  0  

D ITMNO           S             15A  

D TOTAL           S              7  2   

D COUNT           S              2  0      

C/EXEC SQL DECLARE cursor1 CURSOR FOR 

C+ SELECT MACMNO,SUM(MATOTA),Count(MACMNO) from MA01F         C+ Group By MACMNO 

C/END-EXEC   C/EXEC SQL OPEN cursor1    

C/END-EXEC           

C                   DoU       SQLSTT = '02000'     

C/EXEC SQL FETCH Cursor1 INTO :COMNO, :TOTAL, :COUNT          C/END-EXEC                

C                   If        SQLSTT = '02000'   

C                   Leave       

C                   EndIf                

C                   EVAL      P_MACMNO = COMNO    

C                   EVAL      P_MATOTA = TOTAL      

C                   EVAL      P_MACONT = COUNT     

C                   Write     REMA01F         

C                   EndDo      C/EXEC SQL CLOSE Cursor1             

C/END-EXEC                          C                  

EVAL      *InLr = *On   *****************End of Prog***********************

Original Result  hv to come as follows: COMPANY NUMBER   SUM ( MATOTA )   COUNT ( MACMNO )         1                                      848,963.17                53         2                                      316,476.85                21         3                                      418,042.80                20

 But I am getting as :

COMPANY NUMBER  TOTAL AMOUNT  COUNT         

0               .00      0         

0               .00      0         

0               .00      0



Software/Hardware used:
AS400
ASKED: February 1, 2012  7:26 AM
UPDATED: March 17, 2012  5:19 AM

Answer Wiki

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

<pre>Hi, I have posted my SQLRPGLE program, output is not showing down,what mistake i did in my program,please correct it,

FMA01F IF E K DISK

FMA01FTES IF A E K DISK RENAME(RMA01F:REMA01F) PREFIX(P_)
D COMNO S 3 0

D SHPNO S 5 0

D ITMNO S 15A

D TOTAL S 7 2

D COUNT S 2 0

C/EXEC SQL DECLARE cursor1 CURSOR FOR

C+ SELECT MACMNO,SUM(MATOTA),Count(MACMNO) from MA01F
C+ Group By MACMNO

C/END-EXEC C/EXEC SQL OPEN cursor1

C/END-EXEC

C DoU SQLSTT = ’02000′

C/EXEC SQL FETCH Cursor1 INTO :COMNO, :TOTAL, :COUNT
C/END-EXEC

C If SQLSTT = ’02000′

C Leave

C EndIf

C EVAL P_MACMNO = COMNO

C EVAL P_MATOTA = TOTAL

C EVAL P_MACONT = COUNT

C Write REMA01F

C EndDo

C/EXEC SQL CLOSE Cursor1

C/END-EXEC
C EVAL *InLr = *On

*****************End of Prog***********************

Original Result hv to come as follows:

COMPANY NUMBER SUM ( MATOTA ) COUNT ( MACMNO ) 1 848,963.17 53
2 316,476.85 21
3 418,042.80 20

But I am getting as :

COMPANY NUMBER TOTAL AMOUNT COUNT

0 .00 0

0 .00 0

0 .00 0 </pre>

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
  • deepu9321
    Post it in a Code format. It will be better for understanding. Pradeep.
    3,605 pointsBadges:
    report
  • philpl1jb
    Not sure but TOTAL S 7 2 cannot receive number 316,476.85 , it would have to be min of 8 2 no impact but if MA01 is only used in SQL it don't need an F spec FMA01F IF E K DISK Phil
    48,545 pointsBadges:
    report
  • philpl1jb
    the fetch fails because the fields aren't wide enough to accomodate the data but the program continues You only test for SQLSTT = '02000' Normal end of file You would want to make all three variables large enough to accept the largest totals and counts you could ever generate. Phil
    48,545 pointsBadges:
    report
  • 22917
    Thanks Phil Its working ...
    510 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