OP Distinct values

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 Distinct values (connectionID; tableID; fieldID; distinctValues) Longint

ParameterTypeDescription
connectionIDLongintConnection ID with target server
tableIDLongintNumber of the table in the database
fieldIDLongintNumber of the (indexed) field in the table
distinctValuesArrayArray containing disinct values found in
current selection
Function resultLongintError code result for the function

Description

OP Distinct values fills distinctValues with the unique values from fieldID, which is in tableID, from the current selection.

fieldID must be the number of an indexed Alphanumeric field.

distinctValues is an array of type String, Text, Integer, Long Integer, Real, Date, or Boolean.

This function does not change the current selection or the current record.

Error Codes

If OP Distinct values executes successfully, it returns 0. Otherwise, this function returns one of the following errors:

Error CodeDescription
-108Not enough memory to perform this operation.
-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.
10135Invalid parameter type.
10136The connection does not exist.
10153Unable to convert this type of data.
10154This command cannot be executed right now.
10158The field is not an indexed alphanumeric field.

Example

This example presents the user with a list (scrollable area) of today's customers cities.

   C_LONGINT (vRecords; $ErrCode)
   C_STRING (10;vValue)
   ARRAY STRING (25; aCities;0)

   `Compute today's date
   vValue:= String ( Current date ) 

   ` Query for invoices dated of the day, on the [Invoices]Invoice date field (2;3)
   $errCode:=OP Single query (vConnectID;2;3;"=";->vValue;vRecords)

   ` Create a selection of customers for those invoices
   $errCode:=OP Many to one join (vConnectID;1;2)

   ` Load distinct (no duplicates) city names from [Customers]City (1;5) into the aCities array
   $errCode := OP Distinct values (vConnectID;1;5;aCities)

See Also

DISTINCT VALUES, OP Get one field number, OP Selection to array, OP Single query.


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