EcoStruxure Geo SCADA Expert Forum
Schneider Electric support forum about installation, configuration, integration and troubleshooting of EcoStruxure Geo SCADA Expert (ClearSCADA, ViewX, WebX).
Posted: 2020-10-05 09:08 AM . Last Modified: 2023-05-03 12:09 AM
Link copied. Please paste this link to share this article on your social media post.
Posted: 2020-10-05 09:08 AM . Last Modified: 2023-05-03 12:09 AM
SELECT ID,VALUEAsReal, RecordTime, RecordId
FROM CDBHISTORIC
WHERE RecordTime > {ts '2019-10-17 13:00:00'} AND ID = 40776 OR ID = 26114
I am trying to filter the results from CDBHISTORIC like so, I have also tried BETWEEN the chosen date and current timestamp but everything is giving me the same error. It returns all values from those ID's normally with out timestamp filtering.
Error in SQL statement: ODBC-call returned [-1] : [HY000][0][Control Microsystems][ClearSCADA database driver]Historic query not constrained by object, or could not be optimised efficiently
What am I doing wrong?
Link copied. Please paste this link to share this article on your social media post.
Posted: 2020-10-05 09:18 AM . Last Modified: 2020-10-05 09:20 AM
Link copied. Please paste this link to share this article on your social media post.
Posted: 2020-10-05 09:18 AM . Last Modified: 2020-10-05 09:20 AM
Never god **bleep** mind, I literally found the solution two seconds after I posted this. Here is the correct SQL
SELECT ID,VALUEAsReal, RecordTime, RecordId
FROM CDBHISTORIC
WHERE RecordTime > {ts '2019-10-17 13:00:00'} AND (ID = 40776 OR ID = 26114)
You have to put the parenthesis () for the other filters: (ID = 40776 OR ID = 26114)
*sigh* why is my life like this.
Some documentation about this can be found here: http://34.236.135.167/Help/Default.htm#SQLGuide/BuildtheSubClauseList.htm%3FTocPath%3DCore%2520Refer...
Link copied. Please paste this link to share this article on your social media post.
Posted: 2020-10-05 09:18 AM . Last Modified: 2020-10-05 09:20 AM
Link copied. Please paste this link to share this article on your social media post.
Posted: 2020-10-05 09:18 AM . Last Modified: 2020-10-05 09:20 AM
Never god **bleep** mind, I literally found the solution two seconds after I posted this. Here is the correct SQL
SELECT ID,VALUEAsReal, RecordTime, RecordId
FROM CDBHISTORIC
WHERE RecordTime > {ts '2019-10-17 13:00:00'} AND (ID = 40776 OR ID = 26114)
You have to put the parenthesis () for the other filters: (ID = 40776 OR ID = 26114)
*sigh* why is my life like this.
Some documentation about this can be found here: http://34.236.135.167/Help/Default.htm#SQLGuide/BuildtheSubClauseList.htm%3FTocPath%3DCore%2520Refer...
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2020-10-06 10:04 PM
AND takes precedence over OR, so your original query was really
Give me all historic where:
* RecordTime > {ts '2019-10-17 13:00:00'} AND ID = 40776
* OR give me all data for ID = 26114
When you added the brackets you made the logical part change
Link copied. Please paste this link to share this article on your social media post.
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.