Updating an Individual Record’s Values
Learn how to update an individual's record within a set of records with the help of examples.
We'll cover the following
We use the substrReplace
method to insert a decimal separator into a string of numbers. We can make further use of this method to actually update the value of an individual record. For example, we assume the following data string:
1 1200 5 1 2 3232 1
2 3 1600 10 3 4 62200 4
4 5 7700 1 5
We could update the product identifier of the third record quite easily; the steps to do this are straightforward because we only need to determine the starting offset of the product identifier for the given record we are interested in.
Like before, we can determine the initial starting offset by multiplying our target record number by 40. Once we have this, we need to calculate the relative offset of the column we want to update. For our sample invoice data, we have specified that each column of data will contain ten characters in the formatted output.
Updating individual fields within a set of records
We will continue to use zero-based indexes when determining the offsets of a particular field and then multiply that by 10 to arrive at the relative offset. We can add the relative offset to the record’s offset to know where to begin inserting our new data.
Get hands-on with 1400+ tech skills courses.