History Data Storage and Retrieval
History Data Storage and Retrieval
History Data Storage and Retrieval
Module Objectives
z Explain high-level data retrieval and changes to the Historian OLE-DB Provider
z Explain Historian SQL Query structures
z Use SQL examples to show query syntax and data retrieval options
Wonderware Training
Section 1 – Data Retrieval 3-3
Section Objective
z Explain the Data Retrieval Subsystem and Features for the Historian
This section explains the Data Retrieval Subsystem and features for the Historian.
Wonderware Training
Section 1 – Data Retrieval 3-5
In the case of four-part queries, SQL Server produces the statement that is sent to the Historian
OLE DB provider from the statement that the user executes. Sometimes this produced statement
is incorrect, too complex, or lacks portions of the WHERE clause required for the Historian OLE
DB provider to return data.
A typical error message when executing unsupported syntax is:
Server: Msg 7320, Level 16, State 2, Line 1
Could not execute query against OLE DB provider 'INSQL'.
[OLE/DB provider returned message: Historian did not receive a WHERE clause from SQL Server.
If one was specified, refer to the Historian OLE DB documentation]
For four-part queries against non-English SQL Servers running on non-English operating systems,
the default date format might differ from the English versions. For example, for a French or
German SQL Server running on the corresponding operating system, the date/time in a four-part
query must be:
yyyy-dd-mm hh:mm:ss.fff
For example:
2003-28-09 09:00:00.000
Wonderware Training
Section 1 – Data Retrieval 3-7
Wonderware Training
Section 2 – Historian Time Domain Extensions 3-9
Section Objective
z Explain the Data Retrieval Subsystem and Features for the Historian
This section explains the Data Retrieval Subsystem and Features for the Historian.
Time Interpolation
This extension allows data to be retrieved at any point in time even if there is no row at that point in
time.
Why This is Needed
An unassisted database would return data from history for a specified point in time only if there
were an actual row with that time stamp. If there were no row data, complex SQL would be
required to determine the effective value.
How It Is Used
Nothing special is required to use Time Interpolation. This is inherent in the way the Historian
handles all queries to the extension data.
For example the queries:
SELECT Value
FROM InSQL.runtime.dbo.AnalogHistory
WHERE TagName = 'SysTimeHour'
AND DateTime = '20070218 17:45:55'
and
SELECT Value
FROM InSQL.runtime.dbo.AnalogHistory
WHERE TagName = 'SysTimeHour'
AND DateTime = '20070218 17:45:58'
both request data 3 seconds apart, and both return a value of 17, even though the tag
‘SysTimeHour’ is stored cyclically only once every 5 minutes.
The same data from the narrow table looks like this:
Wonderware Training