:Sponsored Link:

Get Quality Web Hosting and Domain Registration in your budget!

Pages: [1]   Go Down
  Print  
Author Topic: How to insert a new record between two existing records in a physical file?  (Read 1778 times)
Rohitha
Newbie
*
Offline Offline

Posts: 6


View Profile
« on: May 08, 2009, 12:48:43 AM »

Hi,

I would like to add a new record into a file at a desired location. How do i achieve this?

A simple write would insert records but in this case they get added at the end. But if it is required to insert a new record in between the 2nd and the 3rd record then Huh

I came across this issue when i was trying to change the source of an RPG pgm..... Roll Eyes by copying the source into a SRCPF.

Thanks
Logged

Thanks,
Rohitha
Niraj
Administrator
Newbie
*****
Offline Offline

Posts: 20


View Profile
« Reply #1 on: May 11, 2009, 01:27:28 AM »

I don't know exactly how we can insert a record in file, in b/w two records. However, I think we can achieve it in following steps
1. Determine the position where we need to insert the record. say rrn = n
2. Copy n to end of file in a temp file.
3. Delete n to end of file.
4. Write our new record.
5. Copy back data from the temp file.

This doesn't look like a decent way though.

Loud thinking- Can we do something by tweaking the sequence number of the source file?
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: