DbSetIndex Function | |
Open an index file and add all its orders to the order list in a work area.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax FUNCTION DbSetIndex(
cIndexFile,
uOrder
) AS LOGIC CLIPPER
[ClipperCallingConventionAttribute(new string[] { ... })]
public static bool DbSetIndex(
Usual cIndexFile = default,
Usual uOrder = default
)
Request Example
View SourceParameters
- cIndexFile (Optional)
- Type: Usual
The name of the index files to open, including an optional drive, directory, and extension for each. See SetDefault() and SetPath() for file searching and creation rules.
The default extension is determined by the RDD and can be obtained using DBOrderInfo(DBOI_INDEXEXT).
If cIndexFile does not exist, a runtime error is raised.
If it exists, this function attempts to open the file in the same mode as the corresponding database file.
If access is denied because, for example, another process is using the file and this one is asking for exclusive use, NetErr() is set to TRUE.
Otherwise, the file open is successful.
Concurrency conflicts with index files are rare since they should be used with only one database file.
If a concurrency problem arises, it will normally be when you attempt to open the database file.
- uOrder (Optional)
- Type: Usual
Order in the index file to activate. When not specified then the first order in the file becomes active.
Return Value
Type:
Logic
TRUE if successful; otherwise, FALSE.
Remarks
By default, this function operates on the currently selected work area.
It can be made to operate on an unselected work area by specifying
it within an aliased expression
If the order list for the work area is empty when DBSetIndex() is issued, the first order in the index file becomes the controlling order.
If there are orders already associated with the work area, they are unaffected — the new orders are simply added to the current order list.
After the new index file is opened (using the same open mode as its associated database file), the work area is positioned to the first logical record in the controlling order.
Opening an index file imposes a logical order (defined by the controlling order) on the records in a database file and may also filter the records according to a for condition or a unique flag.
This means that when you process the database file, the records will appear in the order determined by the controlling order and filtered records, although still physically present in the database file, will be inaccessible.
Tip |
---|
Except for production index files supported by some RDDs, index files are not opened automatically when you open the corresponding database file.
To ensure that index files are accurately maintained, you should either open them prior to making any updates to their corresponding database files or rebuild them at a later time with DBReindex().
|
Examples
The following example opens multiple index files:
1DBUseArea(TRUE, "DBFNTX", "sales", "Sales", TRUE)
2Sales->DBSetIndex("FirstName")
3Sales->DBSetIndex("LastName")
4IF Sales->DBSeek(cLast)
5 IF Sales->Deleted() .AND. Sales->RLock()
6 Sales->DBRecall()
7 QOut("Deleted record has been recalled.")
8 ENDIF
9ELSE
10 QOut("Not found")
11ENDIF
See Also Reference
SetOrderCondition(Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual) DbSetOrderCondition(Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual, Usual)