version 1.5
OP Subselection to array (connectionID; bindID; firstRecord; lastRecord{; tableID}) Longint
Parameter | Type | Description | |
connectionID | Longint | Connection ID with target server | |
bindID | Longint | Bind list ID | |
firstRecord | Longint | Relative number of first record | |
to retrieve in current selection | |||
lastRecord | Longint | Relative number of last record | |
to retrieve in current selection | |||
tableID | Longint | Number of the table in the database | |
Function result | Longint | Error code result for the function |
Description
OP Subselection to array works exactly like OP Selection to array, except that instead of loading values from all records in the selection, it loads values from records relatively placed in the current selection, between firstRecord and lastRecord.
For a complete discussion of this commands functionalities refer to OP Selection to array.
Example
This example exports customer names to a text file. In order to avoid creating large array from a large [Customers] table, it loads the values in 'chunks' of 100 at a time.
C_LONGINT ($errCode;vRecords;$custNamesBind) ARRAY STRING (40;aCustName;0) ` Create a new bind list $ErrCode := OP Create bind ($custNamesBind) ` Add to the list a bind between [Customers]Company (1;2) and the aCustName array $ErrCode := $ErrCode + OP Define bind by pointer ($custNamesBind;1;2;->aCustName) ` Select all records in the [Customers] table (table 1) $ErrCode:= OP All records (vConnectID;1) ` Get the number of records selected $errCode := OP Records in selection (vConnectID;1;vRecords) $i:=0 While ($i<vRecords) ` Load 100 customers names into the array $errCode := OP Subselection to array ( vConnectID; $custNamesBind ; $i+1; $i+100) ExportCustNames (->aCustName) $i := $i + 100 End while $errCode := OP Delete bind ($custNamesBind)
See Also
OP Define bind by pointer, OP Get one field number, OP Records in selection, OP Selection to array, OP Subselection to array.