Like dpQueryConnectAll() but returns as result only two lines (Heading and change to value). For exceptions see: Description. |
Synopsis
int dpQueryConnectSingle(string workfunc, bool wantsanswer, anytype userData, string query,[int blockingTime]); |
Parameters
Parameter |
Meaning |
workfunc |
Name of the work function |
wantsanswer |
Defines whether the work function is to be called spontaneously during registration |
userData |
User-defined data which is passed as parameter to the callback function. |
query |
The query as an SQL statement
CAUTION! Note that for the Connect functions only DPE's of one system may be specified. |
delay |
Timerange in [ms] where the call of the CB-Function from open queries is blocked. Without the entry the value is taken from the config file (see queryHLBlockedTime), with 0 nothing is blocked, otherwise the delay has to be given in [ms](<=32767). |
Return value
dpQueryConnectSingle() returns 0, -1 in the event of an error. Note The return value only indicates whether a CONNECT message was sent, but not whether the execution of the function (query) was successful. The error is written to the thread after the function has been executed and can be retrieved with a subsequent call to the function getLastError(). See also Error Handling. |
Error
Errors can be retrieved with getLastError() . This includes missing arguments (also of the work function), undefined functions, incorrect arguments ( for example, no Control expression), and if no identifier or query is specified. The usage of not initialized variables for the parameter userData will raise an error. |
The function dpQueryConnectSingle() is identical to dpQueryConnectAll() except the type of registration. If a change is made only two lines (Heading and change to value) are returned. If an immediate answer after registration with wantsanswer is "true" is forced, the entire table is returned. The optional parameter delay allows a time definition for blocking queries. That means that the work function is not called immediately after value change, but awaiting the time (indicated with delay) and finally the open queries are transferred at one time to the work function. The registered function workfunc() must have the following transfer parameters: |
void workfunc(anytype userData, dyn_dyn_anytype result) |
Parameters |
Meaning |
userData |
Name for assignment of the function |
result |
Result of the query (two lines: Heading and change to value) |
Notes
|
Example |
main()
{ int rc; anytype userData = getUserName();
setValue("Text1","backCol","Red"); rc = dpQueryConnectSingle("work", true, userData, "SELECT ALERT SINGLE '_alert_hdl.._value' FROM 'E*'"); DebugN("nach QueryConnectSingle: ", rc); }work(anytype userData, dyn_dyn_anytype val) { int i; DebugN("Callback:", dynlen(val), userData); for (i = 2; i <= dynlen(val); i++) DebugN("Wert: ", i, val[i][1], val[i][2], "Benutzer: ", userData); } |
Assignment
Data point function, Waiting Control function |
Availability
UI, CTRL, DP, W |
See also
dpQuery(), dpQueryConnectAll(), dpQueryDisconnect(), isRefresh(), isAnswer(), Basics SQL in Control |
V 3.11 SP1
Copyright ETM professional control GmbH 2013 All Rights Reserved