Skip to main content

KEYPATCH

[ attrname := ] KEYPATCH( index, patchfile, newfile [, OVERWRITE ] [, EXPIRE( [ days ] ) ] [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] );

attrnameOptional. The action name, which turns the action into an attribute definition, therefore not executed until the attrname is used as an action.
indexThe INDEX attribute to apply the changes to.
patchfileA string constant specifying the logical name of the file containing the changes to implement (created by KEYDIFF).
newfileA string constant specifying the logical name of the file to write the new index to.
OVERWRITEOptional. Specifies overwriting the newfile if it already exists.
EXPIREOptional. Specifies the newfile is a temporary file that may be automatically deleted after the specified number of days.
daysOptional. The number of days after which the file may be automatically deleted. If omitted, the default is seven (7).
UNORDEREDOptional. Specifies the output record order is not significant.
ORDEREDSpecifies the significance of the output record order.
boolWhen False, specifies the output record order is not significant. When True, specifies the default output record order.
STABLEOptional. Specifies the input record order is significant.
UNSTABLEOptional. Specifies the input record order is not significant.
PARALLELOptional. Try to evaluate this activity in parallel.
numthreadsOptional. Try to evaluate this activity using numthreads threads.
ALGORITHMOptional. Override the algorithm used for this activity.
nameThe 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);

See Also: KEYDIFF, INDEX