1,240 pts.
 increament values
hi, I have a pf with three records (1,2,3) now i want to update with 1 increment every values Current values are 1,2,3 after update 2,3,4

Software/Hardware used:
ASKED: February 16, 2012  6:42 AM
UPDATED: March 17, 2012  1:25 AM

Answer Wiki:
For updating the Database records, you should first read and then update. In your scenario, Read the PF in a loop till EOF, increment each record with '1' and then update. Pradeep.
Last Wiki Answer Submitted:  February 16, 2012  8:54 am  by  deepu9321   3,520 pts.
All Answer Wiki Contributors:  deepu9321   3,520 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


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


 

Sorry,here i improve my post i have done in sqlrpgle but in rpgle how can i do this

 1,240 pts.

 

[fTEMP2 uf a e k disk
c read temp2
c dow %eof(temp2)
c eval tcod =tcod+10
c update tempr
c* read temp2
c enddo
c eval *inlr=*on ]

 1,240 pts.

 

above i post my code what is wrong in this please check

 1,240 pts.

 

You are almost there.
But, a minor mistake on looping condition is making the program to end without updating.

It should be c dow %eof(temp2)
and, I think you should remove the Comment on read remp2 inside loop.

Pradeep.

 3,520 pts.

 

i have processed in debug mod it directly going to end loop after reading file

 1,240 pts.

 

it directly going to end loop after reading file

just change in your code like

c dow not %eof(temp2)

 3,740 pts.

 

now it goes to infinity loop

fTEMP2     uf a e           k disk           
c                   read      temp2          
c                   dow       not%eof(temp2) 
c                   if        %eof(temp2)    
c                   leave                    
c                   endif                    
c                   eval      tcod =tcod+10  
c                   update    tempr          
c                   read      temp2          
c                   enddo                    
c                   eval      *inlr=*on      
 1,240 pts.

 

Inifity loop??
How many records you are having in your file?

fTEMP2 uf a e k disk
c read temp2
c dow not %eof(temp2)
c eval tcod =tcod+10
c update tempr
c read temp2
c enddo
c eval *inlr=*on

this should work fine.
Try debugging.

Pradeep.

 3,520 pts.

 

only 3 records.
but i found the solution
thanks

fTEMP2     uf   e           k disk                   
c                   read      temp2                  
c                   dow       not%eof(temp2)         
c                   if        %eof(temp2)            
c                   leave                            
c                   endif                            
c                   eval      tcod1=tcod1+10         
c                   update    tempr                  
c                   read      temp2                  
c                   enddo                            
c                   eval      *inlr=*on              
 1,240 pts.

 

here i update keyed field that why its not updated

 1,240 pts.

 

i have add new field tcod1 and tcod is my key field with same data
now its ok

 1,240 pts.

 

are you got the answer or not…..

 3,740 pts.

 

Yes Got the Answer

 1,240 pts.