Click or drag to resize

DbServer.OrderKeyCount Method

X#
Return the number of keys in an order.

Namespace:  VO
Assembly:  VORDDClasses (in VORDDClasses.dll) Version: 2.19
Syntax
 VIRTUAL METHOD OrderKeyCount(
	uOrder,
	oFSIndex
) AS USUAL CLIPPER
Request Example View Source

Parameters

uOrder (Optional)
Type: Usual
The name of the order or a number representing its position in the order list. Using the order name is the preferred method since the position may be difficult to determine using multiple-order index files. If omitted or NIL, the controlling order is assumed. Specifying an invalid value will raise a runtime error.
oFSIndex (Optional)
Type: Usual
A string or filespec object that specifies the name of an index file, including an optional drive and directory (no extension should be specified). Use this argument with cOrder to remove ambiguity when there are two or more orders with the same name in different index files. If oFSIndex is not open by the current process, a runtime error is raised.

Return Value

Type: Usual
Remarks
DBServer:OrderKeyCount() counts the keys in the specified order and returns the result as a numeric value. If the order is not conditional and no scope has been set for it, DBServer:OrderKeyCount() is identical to DBServer:RecCount, returning the number of records in the data server. However, for a conditional order, there may be fewer keys than there are records, since some records may not meet the order's for condition or may not fall inside the scope specified by DBServer:OrderScope()—in counting the keys, DBServer:OrderKeyCount() respects the currently defined scope and for condition.
Tip Tip
If there is no order in operation, DBServer:OrderKeyCount() will return 0 and not the value of DBServer:RecCount().
Examples
This example demonstrates using DBServer:OrderKeyCount() with various orders.
X#
 1oDBCust := Customer{}
 2// Assume 1000 total records,
 3// 500 less than thirty years old, and
 4// 895 making less than 50,000
 5? oDBCust:RecCount                // Result: 1000
 6? oDBCust:OrderKeyCount()            // Result: 0
 7oDBCust:CreateIndex("age", "oDBCust:Age")
 8oDBCust:SetOrderCondition("oDBCust:Age < 30")
 9oDBCust:CreateIndex("first", "oDBCust:FirstName")
10oDBCust:SetOrderCondition("oDBCust:Salary < 50000")
11oDBCust:CreateIndex("last", "oDBCust:LastName")
12// age is the controlling order
13oDBCust:SetIndex("age")
14oDBCust:SetIndex("first")
15oDBCust:SetIndex("last")
16? oDBCust:RecCount                // Result: 1000
17? oDBCust:OrderKeyCount()            // Result: 1000
18? oDBCust:OrderKeyCount("first")    // Result: 500
19? oDBCust:OrderKeyCount(3)        // Result: 895
See Also