version 1.5
OP Multi order by (connectionID; tableID; tableIDs; fieldIDs; orderDirections) Longint
Parameter | Type | Description | |
connectionID | Longint | ||
tableID | Longint | Number of table to order | |
tableIDs | Array | Array of table IDs in the database | |
fieldIDs | Array | Array of field IDs in their tables | |
orderDirections | Array | Array of ordering directions (">" is ascending) | |
Function result | Longint | Error code result for the function |
Description
OP Multi order by orders the target table targetFileID 's current selection by the values in the fields specified by the tableleID and fieldID arrays.
The maximum number of elements for any array is 20. If you pass an array with more than 20 elements, only the first 20 elements of the array will be used, but no error will be returned.
tableIDs and fieldIDs are arrays of type Integer, Longint or Real.
orderDirections is an array of type String, Text, Real, Integer, Long Integer, or Boolean. If orderDirections is of type Text or String, the array should contain one of two values for each table/field to order: ">" to sort in ascending order or "<" to sort in descending order. If orderDirections is a numeric array, a positive value indicates an ascending sort, a zero or negative value indicates a descending sort. If orderDirections is a Boolean array, "true" indicates an ascending sort, while "false" indicates a descending sort.
If parameter checking is on and orderDirections is a Text or String array, any value other than "<" or ">" generates an error. If parameter checking is off, any value not starting with "<" is assumed to indicate ascending order.
4th Dimension performs a sequential sort on the fields chosen even if they are all indexed.
Error Codes
If OP Multi order by 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. |
-9971 | Field number is out of range. |
-9972 | Tale 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. |
10154 | This command cannot be executed right now. |
10155 | Invalid sorting order. |
10156 | Empty search or sort definition. |
Note: If there is an error due to an element of one of the arrays that you have passed, OP Multi order by sets the selected element number of each of the arrays to the number of the faulty element. For example, if there is an error in the fifth element of one of the arrays, the selected element number of all of the arrays is set to 5.
Example
This example orders the selection of invoices by customer company name and invoice date. This example uses the file structure shown in the example for OP Multi query.
C_LONGINT($ErrCode;$TrgFile) ARRAY LONGINT(aTableID;2) ARRAY LONGINT(aFieldID;2) ARRAY STRING(1;aOrder;2) $Trgtable:=2 ` we want to sort the invoice table aTableID{1}:=1 ` [Customers] aTableID{2}:=1 ` [Invoices] aFieldID{2}:=2 ` [Customers]Company aFieldID{3}:=3 ` [Invoices]Date aOrder{1}:=">" aOrder{2}:=">" $ErrCode:=OP Multi order by (vConnectID;$TrgFile;aFileID;aFieldID;aOrder)
See Also
OP Get one field number, OP Multi query, OP Single order by, OP Single query, ORDER BY.