[ attrname := ] KEYPATCH( index, patchfile, newfile [, OVERWRITE ] [, EXPIRE( [ days ] ) ] [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] );
attrname | Optional. The action name, which turns the action into an attribute definition, therefore not executed until the attrname is used as an action. |
index | The INDEX attribute to apply the changes to. |
patchfile | A string constant specifying the logical name of the file containing the changes to implement (created by KEYDIFF). |
newfile | A string constant specifying the logical name of the file to write the new index to. |
OVERWRITE | Optional. Specifies overwriting the newfile if it already exists. |
EXPIRE | Optional. Specifies the newfile is a temporary file that may be automatically deleted after the specified number of days. |
days | Optional. The number of days after which the file may be automatically deleted. If omitted, the default is seven (7). |
UNORDERED | Optional. Specifies the output record order is not significant. |
ORDERED | Specifies the significance of the output record order. |
bool | When False, specifies the output record order is not significant. When True, specifies the default output record order. |
STABLE | Optional. Specifies the input record order is significant. |
UNSTABLE | Optional. Specifies the input record order is not significant. |
PARALLEL | Optional. Try to evaluate this activity in parallel. |
numthreads | Optional. Try to evaluate this activity using numthreads threads. |
ALGORITHM | Optional. Override the algorithm used for this activity. |
name | The algorithm to use for this activity. Must be from the list of supported algorithms for the SORT function's STABLE and UNSTABLE options. |
The KEYPATCH action uses the index and patchfile to write a new index to the specified newfile containing all the original index data updated by the information from the patchfile.
Example:
Vehicles := DATASET('vehicles',
{STRING2 st,
STRING20 city,
STRING20 lname,
UNSIGNED8 filepos{VIRTUAL(fileposition)}},
FLAT);
i1 := INDEX(Vehicles,
{st,city,lname,filepos},
'vkey::20041201::st.city.lname');
i2 := INDEX(Vehicles,
{st,city,lname,filepos},
'vkey::20050101::st.city.lname');
a := KEYDIFF(i1,i2,'KEY::DIFF::20050101::i1i2',OVERWRITE);
b := KEYPATCH(i1,
'KEY::DIFF::20050101::i1i2',
'vkey::st.city.lname'OVERWRITE);
SEQUENTIAL(a,b);