version 1.5
OP Single query selection (connectionID; tableID; fieldID; queryOperator; queryValue; recordsFound) 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 field in the table | |
queryOperator | String | Query operator | |
queryValue | Pointer | Pointer to the object containing the query value | |
recordsFound | Longint | Number of records in the resulting selection | |
Function result | Longint | Error 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:
Operator | Description |
"=" | 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 Code | Description |
-9969 | Invalid field type requested. |
-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. |
10136 | The connection does not exist. |
10144 | The 4D pointer is equal to NIL. |
10145 | A 4D pointer was expected. |
10151 | Invalid search operator. |
10153 | Unable to convert this type of data. |
10154 | This 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.