OP Single query selection

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 Single query selection (connectionID; tableID; fieldID; queryOperator; queryValue; recordsFound) Longint

ParameterTypeDescription
connectionIDLongintConnection ID with target server
tableIDLongintNumber of the table in the database
fieldIDLongintNumber of the field in the table
queryOperatorStringQuery operator
queryValuePointerPointer to the object containing the query value
recordsFoundLongintNumber of records in the resulting selection
Function resultLongintError code result for the function

Description

OP Single query selection queries tableID for queryValues in fieldID. The query is performed on the records in tableID's current selection. After the query, recordsFound indicates the number of records in the new current selection.

queryValue is a pointer to a variable or field that contains the value with which to perform the query. This value can begin with, contain or end with the "@" symbol for wildcard queries. The pointer passed for queryValue can be a pointer to a field, or a process or interprocess variable. If necessary, queryValue is converted.

To query on a Boolean field, you must pass "false" for False and "true" for True.

The query operators are as follows:

OperatorDescription
"="Equal
"#"Not equal
">"Greater than
">="Greater than or equal to
"<"Less than
"<="Less than or equal to

Error Codes

If OP Single query selection executes successfully, it returns 0. Otherwise, this function returns one of the following errors:

Error CodeDescription
-9969Invalid field type requested.
-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.
10144The 4D pointer is equal to NIL.
10145A 4D pointer was expected.
10151Invalid search operator.
10153Unable to convert this type of data.
10154This command cannot be executed right now.

Example

This example searches for records in the [Invoices] file whose grand total is greater than 10,000. It then queries the selection for invoices having dates greater than January 1 of the current year.

   C_LONGINT(vRecords; $ErrCode)
   C_REAL(vValue)
   C_LONGINT(vTable;vField1;vField2)

   $errCode:=OP Get one field number (vConnectID;"[Invoices]Total";vTable;vField1)
   $errCode:=OP Get one field number (vConnectID;"[Invoices]Invoice date";vTable;vField2)
   vValue:="10000"
   $errCode:=OP Single query (vConnectID;vTable;vField1;">";»vValue;vRecords)
   vValue:="01/01/" + String ( year of ( Current date );"####")
   $errCode:=OP Single query selection (vConnectID;vTable;vField2;">";»vValue;vRecords)

   If ($ErrCode=0)
      ALERT(String(vRecords)+" record(s) were found.")
   End if 

See Also

OP Get one field number, OP Multi query, OP Single order by, OP Single query, QUERY SELECTION.


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