| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Creates a new index and/or index file.
DbCreateIndex( <cIndexFile> , ;
<cIndexExpr> , ;
[<bIndexExpr>], ;
[<lUnique>] , ;
[<cIndexName>] ) --> NIL
The return value is always NIL.
The index function DbCreateIndex() creates an index for the database open in the current work area. Use an aliased expression to create an index in a different work area.
If the work area has indexes open, they are closed prior to creating the new index. During index creation, the code block <bIndexExpr> is evaluated for each record of the work area and its return value is added to the index. When index creation is complete, the new index becomes the controlling index. As a result, records are viewed in logical index order and no longer in physical order.
| See also: | DbClearIndex(), DbReindex(), DbSetIndex(), DbSetOrder(), INDEX, OrdCreate(), OrdListAdd(), OrdSetFocus() |
| Category: | Database functions , Index functions |
| Source: | rdd\rddord.prg |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example creates an index file Emp01 on the expression
// Upper(Lastname+Firstname). Note the two notations for the index
// expression.
PROCEDURE Main
USE Employees NEW EXCLUSIVE
DbCreateIndex( "Emp01", ;
"Upper(Lastname+Firstname)", ;
{|| Upper(Lastname+Firstname) } ;
)
? IndexKey() // result: Upper(Lastname+Firstname)
Browse()
RETURN
http://www.xHarbour.com