Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
Good afternoon. I have a need to write a process that will take a changed sales transaction and change the sequence numbers in another file to line up with the new values in the transaction. The sequence number is part of the key to the file and obviously, since records cann be added or removed from the transaction, I can't just chain with the old number and update it with the new value because then we could have a dup key error.
I was playing with the idea of loading a mult occur data structure with all the records in the transaction, deleting the tran and rewriting it with the new seq#, but it appears that I can't have an external data structure defined with dim or occur.
Does anyone have a suggestion as to a simple way to handle this? Any help would be greatly appreciated!
d dsRec ds likerec(FileRec) dim(50)
Interesting. I've never used likerec. Thanks, Neil.
I've had cases like this where I set the numeric values negative so avoid the duplicate keys and then go back ASAP and update them all to positive. Not sure if that helps you or not. And you have to make sure the same program is not running twice (or that could cause a dup key).
Chris R
Good suggestion, Chris. Thanks!
You can have a DIM on an EXTNAME DS, just not the original... use it as a "template" and you're done!
D myExtDS E DS EXTNAME(PICKLES) QUALIFIED D myArray DS LIKEDS(myExtDS) DIM(100)
Ah yes update with negatives, I forgot about that, used that solution when I had the same problem about 15 years ago.... never had a need to do it since then.
You could have the program lock a data area (of the same name) before changing the key values, so if another copy of the program is running, it has to wait its turn. I use something similar but I call it proxy locking (where I can logically flag anything as in use).