0% found this document useful (0 votes)
32 views7 pages

SQL Post Processing PDF

Uploaded by

Edwin Pari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views7 pages

SQL Post Processing PDF

Uploaded by

Edwin Pari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

SQL Post Processing Page 1 of 7

Home > Presentation Services > Excel Add-In > VantagePoint Function Wizards > History
Function> SQL Post Processing
SQL Post Processing
The SQL Post Processing facility is available as an option within the Add-In History Wizard to
transform the times series result set into different result sets. The functionality is based on a query
specification in the SQL Post Processing wizard page.

This wizard is available in the Excel reports and Dashboard report definition.
The wizard has a set of predefined Query templates (which are dependent on the wide/narrow
History request setting).
Queries can be added and modified in the SQL query text field. At any stage the query can be
tested (without applying the result to the spreadsheet) by clicking the [Test] button in the wizard
page.

pdfMachine
A pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click “print”, select the
“Broadgun pdfMachine printer” and that’s it! Get yours now!
http://usmvijdarnold5a/Incuity//Documentation/WebHelp/PresentationServices/Excel/Func... 1/20/2012
SQL Post Processing Page 2 of 7

Once the query has been refined the [Next], [Finish] allows the result set to be applied to the
spreadsheet. The SQL Post Processing is functionality is described below in the Narrow and Wide
table cases.

Narrow Table Case


Wide Table Case

Narrow Table Case


Predefined Templates
Simple #TimeSeries query
The #TimeSeries query is relevant to single or multiple Tags. The simple #TimeSeries query
returns a result set of columns ItemId, TimeStamp, Value, Quality, RowId from #TimeSeries
table based on the time series request StartTime and EndTime specification. By default the
ordering is TimeStamp ascending.
Example:
SELECT ItemId, TimeStamp, Value, Quality, RowId
FROM #TimeSeries
Results:

pdfMachine
A pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click “print”, select the
“Broadgun pdfMachine printer” and that’s it! Get yours now!
http://usmvijdarnold5a/Incuity//Documentation/WebHelp/PresentationServices/Excel/Func... 1/20/2012
SQL Post Processing Page 3 of 7

Duration query
The Duration query is based on a predefined stored procedure [ts_Duration]. This stored procedure
transforms the #TimeSeries table into a result set of TimePeriod’s, returning columns Start,
End and Duration (seconds).
The [ts_Duration] stored procedure has a parameter @aOrdering INT which defaults to 0
(ascending Start ordering) if not specified, if set to a not 0 value the ordering will be descending
Start ordering.
EXEC [dbo].[ts_Duration] -- Ascending Start ordering
EXEC [dbo].[ts_Duration] @aOrdering = 1 -- Descending Start ordering
Example:
EXEC [dbo].[ts_Duration]
Results:

Time-In-State query
The Time-In-State query is pertinent to a single Tag of type Discrete, Integer Analog or String.
The Time-In-State query is based on a predefined stored procedure [ts_TimeInState]. This
stored procedure transforms the #TimeSeries table into a result set of columns Start, End and
Duration (seconds) and TagValue.
The [ts_TimeInState] stored procedure has a parameter @aOrdering INT which defaults to 0
(ascending ordering) if not specified, if set to a not 0 value the ordering will be descending.
EXEC [dbo].[ts_TimeInState] -- Ascending Start ordering
EXEC [dbo].[ts_TimeInState] @aOrdering = 1 -- Descending Start ordering
Example:
EXEC [dbo].[ts_TimeInState]
Results:
pdfMachine
A pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click “print”, select the
“Broadgun pdfMachine printer” and that’s it! Get yours now!
http://usmvijdarnold5a/Incuity//Documentation/WebHelp/PresentationServices/Excel/Func... 1/20/2012
SQL Post Processing Page 4 of 7

Sum In State query


The Sum-In-State query is pertinent to a single Tag of type Discrete, Integer Analog or String.
The Sum-In-State query is based on a predefined stored procedure [ts_SumInState]. This stored
procedure transforms the #TimeSeries table into a result set of columns Sum(Duration)
(seconds) and TagValue.
The [ts_TimeInState] stored procedure has a parameter @aOrdering INT which defaults to 0
(ascending Sum(Duration) ordering) if not specified, if set to a not 0 value the ordering will be
descending Sum(Duration) ordering.
EXEC [dbo].[ts_SumInState] -- Ascending Sum ordering
EXEC [dbo].[ts_SumInState] @aOrdering = 1 -- Descending Sum ordering
Example:
EXEC [dbo].[ts_SumInState]
Results:

Count-In-State query
Count-In-State query, returns Count of Occurrences, Tag Value
The Count-In-State query is pertinent to a single Tag of type Discrete, Integer Analog or String.
The Count-In-State query is based on a predefined stored procedure [ts_SumInState]. This
stored procedure transforms the #TimeSeries table into a result set of columns Sum(Duration)
(seconds) and TagValue.
The [ts_TimeInState] stored procedure has a parameter @aOrdering INT which defaults to 0
(ascending Sum(Duration) ordering) if not specified, if set to a not 0 value the ordering will be
descending Sum(Duration) ordering.
EXEC [dbo].[ts_CountInState] -- Ascending Count ordering
EXEC [dbo].[ts_CountInState] @aOrdering = 1 -- Descending Count ordering
Example: pdfMachine
A pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click “print”, select the
“Broadgun pdfMachine printer” and that’s it! Get yours now!
http://usmvijdarnold5a/Incuity//Documentation/WebHelp/PresentationServices/Excel/Func... 1/20/2012
SQL Post Processing Page 5 of 7

EXEC [dbo].[ts_CountInState] @aOrdering = 1


Results:

Available temporary tables


#TimeSeries table
The #TimeSeries table has columns ItemId, TimeStamp, Value, Quality, RowId, with rows
defined by based on the time series request.

#CoveredTimePeriod table
The #CoveredTimePeriod has one row which specifies the StartTime and EndTime columns
which indicate the request TimePeriod.
Example:
SELECT * FROM #CoveredTimePeriod
Results:

#RefName table
The #NameRef table is a lookup table which correlates the ItemId, TagName and TagFQN for
the Time Series request.
Example:
SELECT * FROM #NameRef
Results:

pdfMachine
A pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click “print”, select the
“Broadgun pdfMachine printer” and that’s it! Get yours now!
http://usmvijdarnold5a/Incuity//Documentation/WebHelp/PresentationServices/Excel/Func... 1/20/2012
SQL Post Processing Page 6 of 7

You can perform a JOIN between #TimeSeries and #NameRef to get the required TagName and
TagFQN:
SELECT NR.TagName, NR.TagFQN, TS.TimeStamp, TS.Value
FROM #TimeSeries TS JOIN #NameRef NR
ON TS.ItemId = NR.ItemId

Wide Table Case


Predefined Templates
ItemId based #TimeSeries query
The wide #TimeSeries query is relevant to multiple Tag item time series requests. The
#TimeSeries query always returns a result set of TimeStamp column and a set of Value columns
based on tag items involved with the time series request. The value column headings are based on
the Tag ItemId’s.
Example:
SELECT * FROM #TimeSeries
Results:

Name based #TimeSeriesName query


The #TimeSeriesName query is similar to the wide #TimeSeries query but the Value column
headings are based on the Tag Names.
SELECT * FROM #TimeSeriesName
Results:

TagFQN based #TimeSeriesFQN query


The #TimeSeriesFQN query is similar to the wide #TimeSeries query but the Value column
headings are based on the Tag fully qualified names (FQN’s).
SELECT * FROM #TimeSeriesFQN
Results:
pdfMachine
A pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click “print”, select the
“Broadgun pdfMachine printer” and that’s it! Get yours now!
http://usmvijdarnold5a/Incuity//Documentation/WebHelp/PresentationServices/Excel/Func... 1/20/2012
SQL Post Processing Page 7 of 7

Available temporary tables


#TimeSeries table
Using on ItemId value column names

#TimeSeriesName table
Using on TagName value column names

#TimeSeriesFQN table
Using on TagFQN value column names

#RefName table
Same as the definition in Narrow Table Case above.

Limitations
Excel formula length limitation
The Excel function specification has a length limitation of 255 characters. If a long query is entered
it will be truncated and will not work.

SQL injection prevention


The SQL that is used within the SQL Post Processing query must not corrupt or alter data in the
IncuityStore database.
All queries are run in contained TSQL transaction which is rolled bacK on completion.
Illegal TSQL commands are detected and not executed.

Copyright 2009 © Rockwell Automation, Inc. All Rights Reserved.


This program is protected by U.S. and international copyright laws as described in the About Box.

pdfMachine
A pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click “print”, select the
“Broadgun pdfMachine printer” and that’s it! Get yours now!
http://usmvijdarnold5a/Incuity//Documentation/WebHelp/PresentationServices/Excel/Func... 1/20/2012

You might also like