Hi,
I'm a newbie when it comes to RPG and I couldn't find anything when searching.
So this is what I need. I'm adding a record to a file but don't want any duplicates so I guess I need s simple RPG proogram that takes in one parm, reads a file (with one field) and if it comes across an exact match, I need to be notified that the record exists.
From there I should be able to modify a CL to alert me if that the record was added, deleted... etc.
Thanks for any help
bgg
Software/Hardware used:
ASKED:
September 14, 2010 8:29 PM
UPDATED:
September 15, 2010 5:43 PM
If you don’t want duplicate records, define the file as uniquely keyed. Then when you attempt to insert a duplicate, your program will be signaled of the error condition.
You can certainly code the process that you asked about, but it’s a long way around to get what the system will give you for little effort.
Tom
Tom’s suggestion is the best answer, because by putting a UNIQUE key on the file, you never have to worry about how the file is updated. If you do a CPYF or DBU, or DFU, it will ALWAYS stop the process and not allow records with duplicate keys.