version 1.5
OP Single query (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 object containing query value | |
recordsFound | Longint | Number of records in the resulting selection | |
Function result | Longint | Error code result for the function |
Description
OP Single query queries tableID for queryValues in fieldID. The query is performed on all the records in tableID. After the query, recordsFound indicates the number of records in the new current selection.
qureyValue 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 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] table whose grand total is greater than 10,000.
C_LONGINT(vRecords; $ErrCode) C_REAL(vValue) C_LONGINT(vTable;vField) vValue:=10000 $errCode:=OP Get one field number (vConnectID;"[Invoices]Total";vTable;vField) $ErrCode:=OP Single query (vConnectID;vTable;vField;">";»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, ORDER BY.