version 1.5
OP Scan index (connectionID; tableID; fieldID; selectionSize; scanOrigin) Longint
Parameter | Type | Description | |
connectionID | Longint | Connection ID with target server | |
tableID | Longint | Number of the table in the database | |
fieldID | Longint | Number of the field in the table | |
selectionSize | Longint | New size for the target table's current selection | |
scanOrigin | Longint | Origin of scan (0 is end of index) | |
Function result | Longint | Error code result for the function |
Description
OP Scan index creates a new selection of selectionSize records for the table specified by taleID. OP Scan index returns a specific number of records from either the top or bottom of the index, depending on the specified direction.
fieldID must be an indexed field. fieldID must be a field from table tableID.
If selectionSize is greater than the number of records in tableID, all the records are selected.
If scanOrigin is less than 0, the records come from the end of the index. If scanOrigin is greater than or equal to 0, the records come from the beginning of the index.
Error Codes
If OP Scan index executes successfully, it returns 0. Otherwise, this function returns one of the following errors:
Error Code | Description |
-9970 | Field is not indexed. |
-9971 | Field number is out of range. |
-9972 | Table number is out of range. |
10128 | The 4D Open for 4th Dimension package has not been initialized. |
10136 | The connection does not exist. |
10154 | This command cannot be executed right now. |
Example
This example creates and prints a selection of this year's invoices out of the top 100 invoices.
C_LONGINT(vRecords; $ErrCode) C_REAL(vValue;vMeanAmount) C_LONGINT(vTable;vFieldDate;vFieldAmount;vFromEnd) $errCode:=OP Get one field number (vConnectID;"[Invoices]Invoice date";vTable;vFieldDate) $errCode:=OP Get one field number (vConnectID;"[Invoices]Invoice amount";vTable;vFieldAmount) ` Scan will be processed from end of index vFromEnd:= -1 ` Create a selection of the top 100 invoices $errCode := OP Scan index (vConnectID;vTable;vFieldAmount;100;vFromEnd) ` Compute this year's 1st of january vValue:="01/01/" + String ( Year of ( Current date ) ;"####") ` Query for this year's invoices out of the top 100 $errCode:=OP Single query selection (vConnectID;vTable;vFieldDate;">";->vValue;vRecords) PrintInvoices
See Also
OP All records, OP Reduce selection, OP Single order by, OP Single query, SCAN INDEX.