OP Multi order by

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 Multi order by (connectionID; tableID; tableIDs; fieldIDs; orderDirections) Longint

ParameterTypeDescription
connectionIDLongint
tableIDLongintNumber of table to order
tableIDsArrayArray of table IDs in the database
fieldIDsArrayArray of field IDs in their tables
orderDirectionsArrayArray of ordering directions (">" is ascending)
Function resultLongintError 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 CodeDescription
-108Not enough memory to perform this operation.
-9971Field number is out of range.
-9972Tale number is out of range.
10128The 4D Open for 4th Dimension package has not been initialized.
10135Invalid parameter type.
10136The connection does not exist.
10154This command cannot be executed right now.
10155Invalid sorting order.
10156Empty 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.


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