version 1.5
OP Distinct values (connectionID; tableID; fieldID; distinctValues) 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 (indexed) field in the table | |
distinctValues | Array | Array containing disinct values found in | |
current selection | |||
Function result | Longint | Error 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 Code | Description |
-108 | Not enough memory to perform this operation. |
-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. |
10135 | Invalid parameter type. |
10136 | The connection does not exist. |
10153 | Unable to convert this type of data. |
10154 | This command cannot be executed right now. |
10158 | The 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.