Hello!
What value and type of value will I get if dpQuery couldn't find any record in WinCC OA's database?
In case of using timerange to make request for example.
return value from dpQuery function
- adaneau
- Posts:310
- Joined: Tue Feb 21, 2012 9:49 am
Re: return value from dpQuery function
Hi,
You'll get an emtpy dyn_dyn_anytype.
BR
Alexandre
You'll get an emtpy dyn_dyn_anytype.
BR
Alexandre
- MassEffect
- Posts:29
- Joined: Mon Aug 24, 2020 8:19 pm
Re: return value from dpQuery function
You'll get an emtpy dyn_dyn_anytype.
How can I check that?
Can I compare empty dyn_dyn_anytype's value with empty string like this:
Code: Select all
if("" == empty dyn_dyn_anytype' value) ...- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: return value from dpQuery function
A dpQuery which was executed without an error will always at least return the header information (1 line in the result table).
You can check with dynlen() if the result of the query contains more than 1 line.
Best Regards
Leopold Knipp
Senior Support Specialist
You can check with dynlen() if the result of the query contains more than 1 line.
Best Regards
Leopold Knipp
Senior Support Specialist
- MassEffect
- Posts:29
- Joined: Mon Aug 24, 2020 8:19 pm
Re: return value from dpQuery function
Does it exist any function that can define type of variable?
For example type of this (after dpQuery request) returnValue[2][2] ?
I recieve two lines ( returned with dynlen() ) and empty value that I get from returnValue[2][2].
For example type of this (after dpQuery request) returnValue[2][2] ?
I recieve two lines ( returned with dynlen() ) and empty value that I get from returnValue[2][2].
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: return value from dpQuery function
If you do a dpQuery() you know which data (and datatype) is returned in which column of the result table.
Then you can define a variable of the same typ and assign the values from the result table by addressing it with [line][column].
Best Regards
Leopold Knipp
Senior Support Specialist
Then you can define a variable of the same typ and assign the values from the result table by addressing it with [line][column].
Best Regards
Leopold Knipp
Senior Support Specialist
- MassEffect
- Posts:29
- Joined: Mon Aug 24, 2020 8:19 pm
Re: return value from dpQuery function
Thank you very much for answers, but how to understand the difference between the empty value and zero?
If I want to compare them result is TRUE for both of them.
If result varible is empty or equal zero:
always returns TRUE
If I want to compare them result is TRUE for both of them.
If result varible is empty or equal zero:
Code: Select all
if(result == 0)- adaneau
- Posts:310
- Joined: Tue Feb 21, 2012 9:49 am
Re: return value from dpQuery function
Hi,
If you wanna know if your query result is empty or not just use:
If you wanna know if your query result is empty or not just use:
Code: Select all
if(dynlen(res)>1)
//not empty
else
//empty- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: return value from dpQuery function
As written in my previous posting you have to know which datatype is saved in which column of the query result if you want to do a comparison.
If a string value is written to a column you can check if the string is emptry by comparing it to "". For numerical values you can do a value comparison.
Best Regards
Leopold Knipp
Senior Support Specialist
If a string value is written to a column you can check if the string is emptry by comparing it to "". For numerical values you can do a value comparison.
Best Regards
Leopold Knipp
Senior Support Specialist