OP Scan index

4D - Documentation   Français   English   German   4D Open for 4D, Command Theme List   4D Open for 4D, Command Alphabetical List   Back   Previous   Next

version 1.5


OP Scan index (connectionID; tableID; fieldID; selectionSize; scanOrigin) Longint

ParameterTypeDescription
connectionIDLongintConnection ID with target server
tableIDLongintNumber of the table in the database
fieldIDLongintNumber of the field in the table
selectionSizeLongintNew size for the target table's current selection
scanOriginLongintOrigin of scan (0 is end of index)
Function resultLongintError 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 CodeDescription
-9970Field is not indexed.
-9971Field number is out of range.
-9972Table number is out of range.
10128The 4D Open for 4th Dimension package has not been initialized.
10136The connection does not exist.
10154This 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.


4D - Documentation   Français   English   German   4D Open for 4D, Command Theme List   4D Open for 4D, Command Alphabetical List   Back   Previous   Next