QMSelect()

Top  Previous  Next

 

The QMSelect function generates a select list containing the ids of all records in a file. It is analogous to use of the QMBasic SELECT statement.

 

 

Format

 

VBQMSelect(ByVal FileNo as Integer, ByVal ListNo) as Integer

 

Cvoid QMSelect(int FileNo, int ListNo)

 

ObjSession->Select(FileNo, ListNo)

 

where

 

FileNois the file number returned by a previous QMOpen() call.

 

ListNois the select list number (0 to 10).

 

 

The QMSelect() function constructs a list of record ids which can subsequently be processed using the QMReadNext() function. Select list 0, the default select list, is used automatically by many QM components to control their action and should, therefore, be used with caution. An unwanted or partially processed select list can be cleared using the QMClearSelect function.

 

See Select lists in QMClient sessions for a description of the alternative ways to handle select list with QMClient.

The QMSelect() function does not provide any method to select only those records that meet specific conditions or to sort the list. These features can be accessed by executing query processor commands using the QMExecute() function.

 

 

Examples

 

VB

QMSelect fClients, 1

Do

  Id = QMReadNext(1, ErrNo)

  If ErrNo <> 0 Then Exit Do

  Rec = QMRead(fClients, Id, ErrNo)

  If ErrNo = 0 Then Go Sub ProcessRecord

Loop

C

QMSelect(fClients, 1);

while((Id = QMReadNext(1)) != NULL)

{

 Rec = QMRead(fClients, Id, ErrNo);

 if (ErrNo == 0)

  {

   ProcessRecord();

   QMFree(Rec);

  }

 QMFree(Id);

}

QMBasic

session->Select(fClients, 1)

loop

  Id = session->ReadNext(1)

until Id = ""

  Rec = session->Read(fClients, Id, ErrNo)

  If ErrNo = 0 then gosub ProcessRecord

repeat

 

The above program fragment builds select list 1 and uses it to process records from the file open as fClients.

 

Note that the C example uses QMFree() to release dynamically allocated memory areas returned from QMClient API calls.