UpdateConditionalIndex Update the Conditional Index Resource in a data file. Short Name UPDCIDX() Type ISAM level function Declaration COUNT UpdateConditionalIndex(COUNT keyno, pTEXT condexpr) Description UpdateConditionalIndex() can add, delete, or change the conditional expression associated with the index. This function assumes an ISAM mapping exists between keyno and an associated data file. The NULL-terminated ASCII string pointed to by condexpr defines the conditions that must be true for an index entry to be made. The expression is stored as a resource in the associated data file. If condexpr is NULL or points to an empty string (“”), the existing conditional expression is deleted. Each index can have at most one conditional expression. If keyno already has an expression, the new expression replaces the old expression. For existing, non-empty files, it is ordinarily necessary to call a rebuild after updating the conditional expressions. UpdateConditionalIndex() checks the syntax of the expression before adding it to the data file resource. The syntax can fail because a name used in the expression is not found in the DODA, or because of an illegal expression. A special case exists with indices created by PermIIndex() and TempIIndexXtd(). By default, both functions create and fill index files in one action without allowing a condition to be set. The ability to separate the index creation from the index build permits UpdateConditionalIndex() to set conditional expressions for the new indices. If PermIIndex() is involved, the data file has its conditional index resource updated. If TempIIndexXtd() is involved, no permanent storage of the conditional index expression is made. The proper steps are:
Note: Do not close the newly created indices between a call to PermIIndex() or TempIIndexXtd() and a call to RebuildIIndex(). UpdateConditionalIndex() creates a temporary conditional index if called for a temporary index. The data file conditional index resource is not updated. Once the temporary index closes, the conditional expression goes with it. To accomplish this:
Return
See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values. Example UpdateMyIndex(pIFIL ifilptr, COUNT keyno, pTEXT condexpr) {
/* This function updates the conditional expression of a given index and rebuilds the index. Requirements include proper c-tree Plus ISAM initialization and IFIL file open. */
return(isam_err);
printf("Rebuild failed after conditional index update.");
return(isam_err); }
return(); } See also PermIIndex(), TempIIndexXtd(), UpdateConditionalIndex(), RebuildIndex(), GetConditionalIndex() |
||||||||||||||||||