Retrieving info about a secondary index¶
OpenIndex() |
Retrieve basic info about a secondary index defined for a data dictionary |
SYNTAX
OpenIndex(pathname, indexnum, indexname, nfields, propnames, propvalues)
Retrieve information about a data dictionary file secondary index. The information retrieved is for the index as a whole. To retrieve information relating to individual fields in the index, use the IndexFieldProp() function.
pathname |
The path of the data dictionary (.d) file. |
||||||
indexnum |
The number of the index, where 1 represents the first secondary index defined, 2 represents the second, etc. |
||||||
indexname |
The index name is returned in this field, which should be alphanumeric. |
||||||
nfields |
The number of fields in the index is returned in this field, which should be a u (unsigned) or i (integer) type. |
||||||
propnames |
Alphanumeric array of 3 elements. The array is filled with the index property names - “include nulls, ”open status” and “usage”. This argument may be NULL. |
||||||
propvalues |
Alphanumeric array of 3 elements. This array is filled with the index property values.
|
The function returns 0 if the file was successfully read, otherwise -1. Possible reasons for failure include permissions, file does not exist, index with this number doesn’t exist, and bad file format.
NOTES
The OpenDotd() function returns general information about a data dictionary, and the FieldProp() function returns properties of a specified field in it. The IndexFieldProp() function returns properties of a specified field in a secondary index.
EXAMPLE
Store index names in an array:
!temp NumDDFields,,i2
!temp NumDDKeys,,i2
!temp NumDDIndexes,,i2
!record IndexNamesRec {
IndexNames,,a30[50]
}
!function GetIndexNames() {
!temp IndexNum,,i2
!temp IndexNamePath,,a255
!temp NumIndexes,,i2
OpenDotd(DDPath, NumDDFields, NumDDKeys, NumDDIndexes)
clear IndexNamesRec
for (IndexNum = 1; IndexNum <= tmp.NumDDIndexes; IndexNum ++) {
if (OpenIndex(DDPath, IndexNum, IndexNamePath) <> 0) {
error "Unable to get information from data dictionary for index number " + tostr(IndexNum)
break
}
SplitPath(IndexNamePath)
IndexNames[IndexNum] = SplitFile
}
return
}
RELATED TOPICS |