dpQuery fails when no dp exists for the queried type

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
5 posts • Page 1 of 1
weirdal
Posts:34
Joined: Thu Mar 12, 2015 11:37 am

dpQuery fails when no dp exists for the queried type

Post by weirdal »

Hi everyone,

we have noticed that a dpQuery statement kind of fails with the following error message when the datapoint type that is being queried does not have any datapoints (yet).

WCCOAui (1), 2020.04.28 09:28:00.297, PARAM,SEVERE, 81, Syntax error, Query not successful, error on fetching header description

The statement looks as follows:
query = "SELECT 'Example1:_original.._value', " +
"'Example2:_original.._value', " +
"'Example3:_original.._value', " +
"'Example4:_original.._value', " +
"'Example5:_original.._value', " +
"'Example6:_original.._value' FROM '*' WHERE _DPT = \"ExampleDPT\"";

Supposedly, the query can not retrieve header information when there are no instances of the given dp type. I also assume that the problem might be the asterisk in the from part.

The result can still be handled since the resulting dyn_dyn_anytype is empty (instead of containing only the headers), but the error message may confuse customers and developers alike.

Is there any way to avoid the above error message when using a dpQuery like this on an empty dp type?

weirdal
Posts:34
Joined: Thu Mar 12, 2015 11:37 am

Re: dpQuery fails when no dp exists for the queried type

Post by weirdal »

Two possibilities:
1) Check whether DPs are existent upfront with dynlen(dpNames(...)) > 0.

2) Put the elements in the FROM section:
query = "SELECT '_original.._value' FROM '{*.Example1,*.Example2}' WHERE _DPT = \"ExampleDPT\"";

leoknipp
Posts:2928
Joined: Tue Aug 24, 2010 7:28 pm

Re: dpQuery fails when no dp exists for the queried type

Post by leoknipp »

The SELECT statement is used to define the attributes you want to query and must not be used to define the datapoints. This is normally done with the FROM statement.

Sometimes it is required to define DP elements in the FROM statement. Then you have to define the DP elements in the SELECT statement and a WHERE _DPT condition to query only datapoints for a specific DP type
E.g.
"SELECT '.UserName:_online.._value' FROM '_Ui_*' WHERE _DPT = \"_Ui\""

The same query can also be made with the following query string:
"SELECT '_online.._value' FROM '_Ui_*.UserName' WHERE _DPT = \"_Ui\""

Best Regards
Leopold Knipp
Senior Support Specialist

weirdal
Posts:34
Joined: Thu Mar 12, 2015 11:37 am

Re: dpQuery fails when no dp exists for the queried type

Post by weirdal »

This only works when you do not want to query separate configs for separate dp elements, tho.

With
"SELECT '.ElemA:_original.._value', '.ElemB:_original.._userbit1' FROM '*' WHERE _DPT = \"Type\""
it's not possible to use the other syntax, is it?

leoknipp
Posts:2928
Joined: Tue Aug 24, 2010 7:28 pm

Re: dpQuery fails when no dp exists for the queried type

Post by leoknipp »

If you want to get different attributes for different elements you can use the syntax you have written.
When defining only the attributes in the SELECT statement you get them for all DP elements.

Best Regards
Leopold Knipp
Senior Support Specialist

5 posts • Page 1 of 1