sx_QueryRecCount

<< Click to Display Table of Contents >>

Navigation:  Apollo API Listing >

sx_QueryRecCount

VB Declaration

Declare Function sx_QueryRecCount Lib "Apollo9.dll" () As Long

C Declaration

LONG FAR PASCAL sx_QueryRecCount (VOID);

Description

Extracts the number of records contained in the current query subset.

Return Value

The record count. The number of records returned is calculated in the following order.

1. If there is a fully optimized query and/or scope bitmap present, the function very quickly returns the number of records in the subset. Deleted records are included in the count.

2. If there is no query or scope bitmap set and the controlling index is not a conditional index and there is no standard filter set, this function returns the total number of records in the table (same as sx_RecCount). Deleted and filtered records are included in the count.

3. If the controlling index is a conditional index the number of keys in the conditional index is returned. This number includes deleted and filtered records.

4. If there is a partially optimized bitmap present or a standard filter, the number returned is the actual count of records. Deleted and filtered records are excluded from the count (same as sx_Count). The function must evaluate every record represented in the bitmap (or even in the entire table if no part of the query was optimized). In this case it can be slow.

VB Example

' Display database info

Text4.Text = sx_BaseDate()

Text5.Text = sx_RecSize()

If FilterOn Then

Text6.Text = sx_QueryRecCount()

Else

Text6.Text = sx_RecCount()

End If

C Example

// call query

lRecNum = sx_Query(caString);

if (lRecNum)

{

// in case we're on a record that doesn't meet the condition

sx_GoTop();

 

lNumRecs = sx_QueryRecCount();

_fmemset(caNumRecs, 0, (size_t) sizeof(caNumRecs));

ConvertLtoA(lNumRecs, caNumRecs, 7);

lstrcpy((LPSTR) caExpression, (LPSTR) caNumRecs);

lstrcat((LPSTR) caExpression, " records found");

}

else

lstrcpy((LPSTR) caExpression, "0 records found");

SendMessage(hStatBar, SBM_DISPLAYTEXT, (WPARAM) 0,

(LPARAM) ((LPCSTR) caExpression));

See Also

sx_Count, sx_FilterDlg, sx_Query, sx_QueryTest, sx_RecCount