PI Interface For Relational Databases (PI RDBMS Via ODBC) 3.21.4 User Guide
PI Interface For Relational Databases (PI RDBMS Via ODBC) 3.21.4 User Guide
User Guide
OSIsoft, LLC
777 Davis St., Suite 250
San Leandro, CA 94577 USA
Tel: (01) 510-297-5800
Fax: (01) 510-357-8136
Web: http://www.osisoft.com
SQL examples..........................................................................................................71
Example 1: Update a single tag with single value using key matching.............................................................71
Example 2: Update a single tag with most recent values from database.........................................................72
Example 3: Update three points from a single row......................................................................................... 72
Related manuals
• RDBMS interface quickstart in the OSIsoft Knowledge Base
• PI Server manuals
• PI API and SDK help
• YouTube videos in the OSIsoft Learning Channel
• Database vendor’s ODBC driver manual
• UniInt Interface User Manual
• Microsoft ODBC Programmer's Reference
• Timestamp
• Value
• Status
• Annotation (optional)
To write data from the PI System to the RDBMS, you define output tags, which are associated
with INSERT, UPDATE or DELETE queries.
Queries can contain placeholders for replaceable parameters. Placeholders are evaluated when
the query is executed.
For efficiency in reading data from the RDBMS and writing it to the PI System, the interface
supports several distribution strategies, depending on the structure of the result rows returned
by the SELECT query:
• One PI point value per row: Each row returned in the result set returned by the SELECT
query contains a single time stamp, value, status and (optionally) annotation, but no PI tag
name. For details, see Updating a single tag.
• Multiple PI point values per row (the "tag group" approach): Each row in the result set
contains values for more than one PI point. To associate a specific column with a PI point,
you specify the column position in the Location3 point attribute. For details, see Updating
a predetermined set of tags (tag groups)
• Read the PI point name from the row: To handle result sets that include rows for multiple PI
points, the interface provides the "tag distribution" and "RxC" (row by column) distribution
approaches, depending on whether the row includes one value for one tag or values for
multiple tags. For details, see Updating from multi-value rows containing name of target
points (RxC).
Tags can be scanned or event-driven. Scanned tags are read or written at a regular interval that
is defined by the scan class assigned to the tag. Event-driven tags are read or written when a
specified trigger tag is updated. The interface provides several options for handling data that
does not arrive in timestamp sequence (out-of-order data).
Besides collecting data in real time, the interface can recover historical data from the PI
Archive to an RDBMS or from the RDBMS to the PI System. You can configure the period to be
restored, and after recovery is complete, the interface can either exit or begin collecting real-
time data.
The interface runs on Windows either as a console application or Windows service. It uses
ODBC to connect to the RDBMS. For the ODBC connection, you define the data source name
(DSN) using the Data Sources (ODBC) Windows control panel and configure the interface
instance to connect to the database using the DSN. The following figure illustrates a typical
configuration, with the PI Server, RDBMS and interface running on different nodes.
Error logging
Messages are logged to the local PI message log during interface startup, data collection and
recovery. Additional messages are logged if you enable debugging. The log also lists messages
from the UniInt framework and PI API (on which this interface is based), and from the
buffering program. To view the message log, use the PI System Management Tools (PI SMT)
Operation > Message Logs feature.
For detailed information about interface logging, see the following OSIsoft Knowledge Base
topic How to read new UniInt 4.5.0.x and later Interface message logs (now in PI Message Log,
not PIPC.log) (https://customers.osisoft.com/s/knowledgearticle?
knowledgeArticleUrl=KB00401).
For details about managing the error logging process, see the PI API Installation Instructions
(https://customers.osisoft.com/s/productcontent?id=a7R1I000000XyTuUAK) user guide.
Prerequisites
Before installing and configuring, ensure that the following requirements are met.
OSIsoft prerequisites
• Verify that the RDBMS is running, populated with any required data, and is accessible using
ODBC. To test connectivity and validate the syntax of SQL queries, you can use the Microsoft
ODBC Test application.
• Ensure that the ODBC driver is correctly configured, as follows:
◦ The ODBC driver, client and any necessary database client software must be configured
in the system path.
◦ The ODBC driver must support Level 1 API conformance, which consists of the Core
interface conformance level functionality plus additional features such as transactions
that are usually available in an OLTP relational DBMS.
◦ The ODBC data source must be defined as a system data source name. On 64-bit
operating systems, configure the DSN using the 32-bit ODBC Administrator, which is
located in %systemroot%\syswow64\odbcad32.exe.
Create trusts
To provide the interface with access to the PI Server, you must define trusts. When creating
trusts for PI interfaces, you have many options. For detailed information about trusts and PI
System security, refer to the PI Server System Management Guide.
Following is a simple and secure approach, creating a trust for the following applications:
• RDBMSPI interface
• PI Interface Configuration Utility (ICU)
• Buffering
To create each of these trusts using PI System Management Tools, connect to the PI Server and
perform the following steps:
Procedure
1. Click Security and choose Mappings & Trusts.
2. On the Trusts tab, right-click and choose New Trust. The Add Trust wizard is launched.
Procedure
1. Launch PI ICU.
2. Choose Interface > New Windows Interface Instance from BAT File. The Open Interface
Configuration File dialog is displayed.
3. Browse to the directory where the interface is installed (the default is %PIPC%\Interfaces
\RDBMSPI), select RDBMSPI.bat_new and click Open. The Select PI Host Server dialog is
displayed.
4. Specify the PI Server and click OK. ICU displays the settings of the new instance of the
interface.
5. On the General tab, edit the basic settings as follows.
◦ Point source: "RDBMS" or a point source not already in use
◦ Interface ID: 1 or a numeric ID not already in use
◦ Scan class: Configure desired scan frequency. Note that, when defining scan classes, you
can spread the server workload using offsets, to ensure that all scans do not occur at the
same time.
6. Configure interface-specific settings on the rdbodbc tab. See PI ICU reference for the PI
RDBMS interface for more information.
Procedure
1. To display the message log, launch PI System Management Tools and choose the Operation
> Message Logs menu option.
2. To start the interface using PI ICU, choose Interface > Start Interactive.
PI ICU displays a command window and invokes the startup batch file, and you can observe
progress as the interface attempts to initialize and run.
3. Watch log for messages indicating success or errors.
4. To stop the interface, close the command window.
Procedure
1. Launch PI ICU and click the Service tab in the PI ICU window.
2. Set Startup Type to Auto.
3. Set the fields as described in the following table.
Field Description
Service name Descriptive name of the interface service.
ID Numeric ID of the interface instance. Must be unique for each instance.
Display name The service name displayed in the Windows Services control panel. The default
display name is the service name with a PI- prefix. You can override the default. To
ensure that OSIsoft-related services are sorted together in the Services control
panel, retain the PI- prefix.
Log on as The Windows account associated with the service. Set password expiration to
Never.
Password Password, if any, for the preceding user.
Dependencies Any services that the interface depends on. The only dependency is the TCP/IP
service, which is pre-configured. If buffering is enabled, you are prompted to create
a dependency on the buffering service.
Startup type Specifies whether the interface service starts automatically when the interface node
is restarted. Generally, interface services are set to start automatically.
Enable buffering
This is a summary of how to start buffering. For detailed information about buffering, refer to
the PI Buffering User’s Guide.
Procedure
1. In ICU, choose Tools > Buffering. The Buffering dialog is displayed.
2. Click Enable buffering with PI Buffer Subsystem, then click Apply.
3. To start the buffering service, click PI Buffer Subsystem Service, then click .
4. To verify that buffering starts successfully, check the message log for messages indicating
that the buffering application connected to the PI Server. To verify that the configuration is
working as intended, reboot the interface node and confirm that the interface service and
the buffering application restart.
Optional configuration
The following are useful, but not required:
Note:
For details, consult the UniInt Interface User’s Guide.
• Configure diagnostics
Diagnostic PI points enable you to track the activity and performance of the interface.
• Configure disconnected startup
Disconnected startup enables the interface to start and collect data if the PI server is not
available.
• Configure failover
Failover enables the PI System to switch to another copy of the interface if the currently-
running instance fails.
• Install the PI Interface Status Utility
This utility enables you to monitor the state of the interface. For details, see the PI Interface
Status Utility (ISU) User Manual.
Point attributes
The point attributes are used to indicate how the interface uses the point. You set them when
configuring points to be read or written by the interface. For example point configurations,
refer to SQL examples.
If your PI Server is earlier than version 3.4.370.x or the PI API version is earlier than 1.6.0.2
and you want to create points with names that exceed 255 characters, you must enable the PI
SDK.
Note:
If the source point name length exceeds 80 characters, you must use the UserInt1
attribute for source point mapping, due to a limitation of the PI API.
sensitive. In the interface batch startup file, the point source is specified using the /PS
command-line parameter.
The following point sources are reserved. Do not configure them for interface instances.
Point Source Reserved By
T Totalizer Subsystem
G and @ Alarm subsystem
R Random interface
9 RampSoak interface
C Performance equations subsystem
• Input points
To configure handling of out-of-order data for an input point, set Location5 as follows:
Value Description
0 Enable standard exception reporting and out-of-
order data handling for a tag. If the PI Archive
already contains an event with the same time
stamp as the incoming event, the archived event
is not replaced with the incoming event.
1 Disable exception handling and send all incoming
values to the snapshot. For out-of-order data,
existing events are replaced and new events are
added.
2 Archive all incoming out-of-order values. If you
set Location5 to 2, you risk the possibility of
multiple events with the same time stamp.
• Output points
To configure handling of out-of-order data for an output point, set Location5 as follows:
Value Description
-1 Disable out-of-order data recovery for a tag
(query is not executed)
0 Enable out-of-order data handling and output
recovery for new events. Out of order data errors
are logged as -109 errors in the PI message log.
1 Enable enhanced out-of-order data processing
(per-event-type handling)
• Events
To enable out-of-order data handling for specific types of events, set the desired options
using PI ICU, on the rdbodbc > Recovery Parameters tab. To define queries that handle
events according to their type, define the query using the @source options for new,
replacement and deletion events. For example:
IF @source_appended INSERT INTO table (…);
IF @source_replaced UPDATE table SET column1 = ? …;
IF @source_removed DELETE table WHERE column1 <= ?;
The @source options are supported only for output tags. For details about handling events
on a per-type basis, see Handling events by type.
The interface recovers events from the archive during startup and output recovery. By
default, only new events are recovered. To enable recovery of replacement and deletion
events using PI ICU, set the desired options on the rdbodbc > Recovery Parameters tab. In
real-time mode, deletion events are not processed.
To assign values to replaceable parameters in SQL queries, you specify placeholders in the
ExDesc attribute. Replaceable parameters in queries are indicated by question marks. For a
detailed explanation, see Placeholders for replaceable parameters.
To designate a performance point, set ExDesc to PERFORMANCE_POINT. For details, refer to the
PI Interface for Performance Monitor user’s guide.
Note:
The maximum length of the ExDesc attribute depends on the versions of the PI Server
and API in use. If PI API is version 1.6.0.2 or higher and PI Server is 3.4.370.x or higher,
the maximum length is 1023. For all lower versions, the maximum is 80. If the PI Server
version is earlier than 3.4.370.x or the PI API version is earlier than 1.6.0.2, and you
require more characters, enable the PI SDK.
SourceTag
For output tags (points that write data to the RDBMS), this attribute specifies the PI tag that
triggers query execution and from which the data is read (unless the output tag’s query uses
placeholders to derive the data from other tags).
Scan
This attribute enables or disables data collection for the PI point. By default, data collection is
enabled (Scan is set to 1). To disable data collection, set Scan to 0. If the Scan attribute is 0
when the interface starts, the interface does not load or update the point. If you enable
scanning while the interface is running, the time required for data collection to start depends
on how many points you enable, because they are processed in batches. For efficiency, if you
need to enable scanning for a large number of points, stop and restart the interface. If a point
that is loaded by the interface is subsequently edited so that the point is no longer valid, the
point is removed from the interface and SCAN OFF is written to the point.
Shutdown
By default, the PI Shutdown subsystem writes the SHUTDOWN digital state to all PI points when
PI Server is started. The time stamp that is used for the SHUTDOWN events is retrieved from a
file that is updated by the snapshot subsystem. The time stamp is usually updated every 15
minutes, which means that the time stamp for the SHUTDOWN events is accurate to within 15
minutes in the event of a power failure. For additional information on shutdown events, refer
to PI Server manuals.
Note:
The SHUTDOWN events that are written by the PI shutdown subsystem are independent of
the SHUTDOWN events that are written by the interface.
To prevent SHUTDOWN events from being written when PI Server is restarted, set the Shutdown
attribute to 0. To configure the PI shutdown subsystem to write SHUTDOWN events only for PI
points that have their Shutdown attribute set to 1, edit the \\PI\dat\Shutdown.dat file, as
described in PI buffering documentation.
• ExcMax: The maximum time period allowed between sending values to the PI Server.
• ExcMin: The minimum time period between values sent to the PI Server.
• ExcDev: The minimum change from the last value sent to the PI Server required for the
interface to send a new value.
Exception processing is not performed for queries that include PI annotations: all data
retrieved by such queries is archived.
To further filter the amount of data that is captured, you can configure a tag’s compression
settings so that only meaningful deviations are archived. For more information about exception
processing and compression, see the UniInt Interface User Manual.
Event-based input
Input points can be event-based: whenever the snapshot value of a trigger tag changes, an
event is generated and the SQL statement gets executed. To configure the trigger tag, specify /
EVENT=TagName or /TRIG=TagName in the input tag's extended descriptor attribute. For
details about defining trigger tags and specifying conditions for them, refer to UniInt Interface
User’s Guide.
Digital tags
To store values from a digital output tag in the RDBMS, you must define the target column
using a string data type. The following table shows how value placeholders for a digital tag are
evaluated:
Digital state in range of bad VL Field type string SS_I integer or float SS_C field type string
inputs?
No <Digital State String> 0 "O.K."
Yes <Digital State String> 1 "Bad Value"
To associate a query file with a tag, specify the name of the file in the InstrumentTag attribute
and specify placeholders for replaceable parameters in the ExDesc attribute. In query files,
omit the /SQL flag. For example:
Query execution
Before a query is executed, the interface checks its syntax. If the syntax is invalid, the interface
logs a Tag refused message describing the problem. To ensure that the syntax of a query is
valid, test the query using a third-party ODBC query tool (for instance, the Microsoft ODBC Test
application).
The queries executed by your tags can contain single or multiple SQL statements, each
terminated by a semicolon. Each statement is committed after execution (AUTOCOMMIT) unless
you enable transaction semantics for the tag by specifying the /TRANSACT keyword in the
ExDesc tag attribute.
• SELECT
• INSERT
• UPDATE
• DELETE
• {CALL}
Note:
Proprietary language constructions such as T-SQL and PL/SQL are not guaranteed to
work. For example, the MS SQL Server's T-SQL is supported for use with the MS SQL
ODBC driver, but similar constructions fail with an Oracle ODBC driver. If you require
logic to control the flow of execution, use stored procedures.
To optimize performance, the interface executes SQL queries using prepared execution. SQL
queries are compiled the first time they are executed, and the compiled queries are used for
subsequent executions. Some ODBC drivers limit the number of prepared statements
permitted. If your ODBC driver enforces a maximum, you can disable prepared execution using
PI ICU: Go to the rdbodb > Optional Parameters tab and check Direct SQL execution.
By default, each statement in a multi-statement query is committed separately (AUTOCOMMIT).
To execute all statements in a single transaction, specify the /TRANSACT keyword in the
ExDesc attribute. If all statements succeed, the transaction is committed. If any statement fails,
all statements are rolled back.
If the query fails the first time it is executed, the tag is removed from processing. For output
tags, if the query fails, the output tag is assigned the Bad Output state.
Stored procedures
Queries can execute previously-defined stored procedures. Stored procedure calls can use
placeholders (input parameters) in their argument lists. To call a stored procedure, use the
following syntax:
{CALL procedure-name[([parameter][,[parameter]]…)]}
Output parameters are not supported. Stored procedures are therefore mainly useful for
complex actions that cannot be expressed using the SQL syntax that the interface supports. For
an example of the use of stored procedures, see Example 24: Stored procedure call.
• @query_success: TRUE if query succeeded (all values written to PI System), FALSE if query
failed
• @query_failure: FALSE if query succeeded, TRUE if query failed
You can define an IF statement that conditionally issues a single SQL statement depending
on the state of the variable. For example:
You can define an IF statement that conditionally issues a single SQL statement depending on
the state of the variable. For example:
SELECT Timestamp, Value, 0 FROM Table WHERE Timestamp > ? ORDER BY Timestamp;
IF @query_failure
INSERT INTO Table2 (Timestamp, Tag, error_message)
VALUES (?,?,'Query failed');
Note that the interface does not support an ELSE clause for the IF statement.
• @write_success: TRUE if query succeeded (all values written to PI System), FALSE if update
failed.
• @write_failure: FALSE if query succeeded, TRUE if it failed.
These variables are set when the first query is executed.
You can define an IF statement that conditionally issues a single SQL statement depending on
the state of the variable. For example, to determine whether rows in the RDBMS have been
successfully written to tags and can therefore be deleted from the RDBMS, use the following
logic:
SELECT Timestamp, Value, 0 FROM Table WHERE Timestamp > ? ORDER BY Timestamp;
P1=TS
IF @write_success DELETE FROM Table WHERE Timestamp <= ?;
To determine whether tag distribution succeeded, you must use the @rows_dropped variable.
For details, see Verifying successful data distribution.
Note that the placeholders are numbered and must be specified in ascending order.
The next example illustrates how data from events in the PI Archive are transferred through
placeholders to an RDBMS table for various PI data types. The example is based on the
following query:
/SQL="INSERT INTO Table
(name, instant, ColFloat, status_num, status)
VALUES (?,?,?,?,?);"
P1=AT.TAG P2=TS P3=VL P4=SS_I P5=SS_C
Values are assigned in order: the first replaceable parameter is assigned the value of the
placeholder assigned to P1, the second replaceable parameter is assigned the value of the
placeholder assigned to P2, and so on. When specifying placeholders, separate them with
spaces or tabs (white space); for example:
For string constant placeholders, specify the argument in double quotes; for example:
P1="MYTAGNAME"
If the same placeholder definition is used multiple times in a query, it is possible to shorten the
definition string using a back-reference; for example: P5=P3
To define frequently-used placeholders or to define a large number of placeholders, you can
create a global variables file. To use PI ICU to configure the name of the global variables file to
be used by the interface instance, go to the rdbodbc > Startup Parameters tab and set the
Global Variables File field. The syntax of global variables is the same as local placeholders, but
global placeholder names start with G instead of P.
To derive data from a tag other than the tag associated with the query, you can qualify a
placeholder with the name of the tag. For example, to derive the value from another tag,
precede the VL placeholder with the name of the tag in single quotes as follows:
P1='SINUSOID'/VL.
The following table shows how the interface evaluates placeholders for output tags. Values
from digital PI tags must correspond to string columns in the RDBMS.
PI point data type Event state Placeholders
VL SS_I SS_C
Float, Timestamp, No error <Value> 0 "O.K."
Integer, String Error < Previous Value> <Digital State String> <Digital State String>
Digital Digital state is in the <Digital State String> 0 "O.K."
range of success
statuses
Digital state is in the <Digital State String> 1 "Bad Value"
range of "bad"
statuses
To configure the value to be used when no value exists at the specified time stamp, set the mode
parameter as follows:
'tagname'/VL('timestamp',mode)
For output tags, the time stamp is usually the time from the source tag event. If a value exists at
the specified tim estamp, the value is used. Valid values for the mode parameter are as follows:
Mode Value used
Previous The first value before the specified time
Next The first value after the specified time. Specified time
cannot exceed snapshot time.
Interpolated Interpolated value at the specified time
Snapshot Placeholders
Placeholder SQL (ODBC) Data Type
First choice Second choice
ST SQL_TIMESTAMP
TS
LET
LST ANN_TS
The time stamp column is optional. If you omit the time stamp, the value is written using the
interface node system time. If the source table does not include a status column, you can
specify a numeric value in the query (0 indicates good data):
SELECT Timestamp, Value, 0 FROM Table…
• PI_TIMESTAMP
• PI_VALUE
• PI_STATUS
• PI_ANNOTATION
For example:
For example:
SELECT Timestamp AS PI_TIMESTAMP, Value AS PI_VALUE, Status AS PI_STATUS,
Annotation AS PI_ANNOTATION FROM…
When you use aliases, the columns in the SELECT statement can be specified in any order –
they are not required to be in the timestamp/value/status sequence required by the fixed
position approach. When the columns in the SELECT list are aliased, the status column is not
mandatory. If status is omitted, the interface writes a status of 0 (Good) to the tag.
If the query retrieves multiple tag values from a single row, you can use numbered aliases to
assign the results columns to target tags. The number of the alias corresponds to the value that
you specify in the Location3 attribute of the target tag. For details, see Updating a
predetermined set of tags (tag groups).
Where value_exp is a column name, result of a scalar function, or a literal, and data_type
specifies a valid SQL data type.
For example, the following expression converts the output of the CURDATE() function to a
string:
{Fn CONVERT({Fn CURDATE()},SQL_CHAR)}
For details about CONVERT(), refer to the MSDN Library or your ODBC driver documentation.
The syntax for CAST() is as follows:
CAST ( { expression | NULL } AS data_type [(length)] )
For example, the following expression converts the selected value to a string:
SELECT Timestamp, CAST(Value AS Varchar(64)), Status FROM…
For details about CAST(), refer to your RDBMS vendor’s SQL reference guide. For a full
description of the ODBC-supported data types, see the ODBC Programmer's Reference, which is
available from the MSDN web site (http://msdn.microsoft.com/en-us/library/
ms714177.aspx).
Handling NULLs
When updating PI tags with data from the RDBMS, the interface handles NULLs as follows:
To ignore null values for tags populated using the tag group and RxC distribution strategies,
enable the Ignore Nulls option on the PI ICU rdbodbc > Optional Parameters tab.
Annotations
PI annotations can handle any data type returned by a query. The interface treats the column
that contains annotations as one of the following data types:
• Time stamp
• Tag value
• Status
• Annotations
To ensure that SQL data types are compatible with data types supported in PI Server, cast the
result columns to a compatible data type.
Note:
The interface does not support Unicode. If a SELECT query returns a NVARCHAR (Unicode)
result column, the interface logs an error message such as the following:Point -
MyTag : Unsupported RDB column MyColumn type -9. To avoid such errors, cast
Unicode result columns to an equivalent non-Unicode data type.
• Time stamp
The result column must have a data type of DATETIME or a compatible data type, depending
on your RDBMS.
• Tag name
The result column must be a string type such as CHAR or VARCHAR.
• Tag value
For input points, the interface casts results from the RDBMS to compatible PI data types as
follows:
ODBC data RDBMS data Target PI point data type
type type
Float Integer Digital String
• Status
The status field indicates the state of the target tag. To map the values in the RDBMS to valid
PI status values, use PI ICU to configure the following settings on the rdbodbc > Startup
Parameters tab:
Time stamps
The implementation of the timestamp data type varies among vendors, so the interface uses
the ODBC SQL_TIMESTAMP data type, which enables the interface to handle time stamps
consistently without regard for the underlying RDBMS. The interface can handle UTC
timestamps from both the RDBMS and the PI System. If the time stamps in the RDBMS are
stored as UTC data, enable UTC handling using PI ICU: go to the rdbodbc > OptionalParameters
tab and check Times are UTC.
Time stamps must specify both date and time of day. The interface does not provide any
defaults for either value. The PI Server rejects time stamps that are more than ten minutes
ahead of its system time. To prevent this problem, make sure that the system time on the PI
Server and RDBMS host computers are synchronized and, if necessary, define queries that
return only rows that are time stamped less than ten minutes ahead. The following example
illustrates this approach; sysdate is Oracle's "current time" function, and "10*60/86400" is an
expression for ten minutes:
SELECT Timestamp,Value,0
FROM TestTable
WHERE Timestamp > ? AND Timestamp < sysdate+10*60/86400
ORDER BY Timestamp; P1=TS
When the interface starts, all time stamp placeholders are populated with the current snapshot
time stamp, to ensure that all values added to the table since the last successful scan are
returned by queries like the following:
SELECT Timestamp, Value, Status
FROM TestTable
WHERE Timestamp > ?
ORDER BY Timestamp; P1=TS
The interface caches the most recent timestamp returned by the last-executed query and
uses it as the value for the TS placeholder. This approach has the following effects on
subsequent SELECT queries that use the TS placeholder to retrieve newly-arrived data:
◦ If buffering is enabled, the interface can execute the query even if it loses connectivity to
the PI Server.
◦ Regardless of whether exception reporting is enabled, newly-arrived rows are always
returned by the query.
Queries that are intended to retrieve newly-arrived rows must sort results by time stamp.
For example:
SELECT … FROM … WHERE timestamp > ? ORDER BY timestamp; P1=TS
To retrieve the time stamp of the system time on the RDBMS host computer, specify the
ODBC function {Fn NOW()} or use the appropriate database-specific function. For example:
SELECT {Fn NOW()},Value, Status FROM Table WHERE …;
If a SELECT statement omits the timestamp column, the interface uses the system time from
the interface node when the query is executed.
• Time stamp precision
The PI System can handle time stamps with precision up to 100 microseconds. For example,
20-Mar-2013 11:10:01.1234 is a valid PI time stamp. However, the maximum precision of
time stamps in the RDBMS might differ from the PI System maximum. Current time stamps
generated by the interface always contain the millisecond part.
• Numeric time stamps
In SELECT statements, you can specify time stamps using the SQL_TIMESTAMP data type or
as a DOUBLE or INTEGER column containing the number of seconds since 01-Jan-1970 (Unix
time stamps). Unlike SQL_TIMESTAMP, numeric time stamps can specify sub-millisecond
time stamps. To specify time stamp columns using a numeric data type, you must use the
"PI_TIMESTAMP" alias or cast the numeric column to a valid time stamp. The following
example query illustrates the use of a numeric column as a time stamp. (Note that the
to_date function is Oracle-specific.)
SELECT Time-as-number AS PI_TIMESTAMP, Value AS PI_VALUE, 0 AS PI_STATUS
FROM TestTable
WHERE (to_date('01-Jan-1970') + Time-as-number/(24*3600)) > ?; P1=TS
To use numeric time stamps in the WHERE clause or with placeholders, you must cast them
to a time stamp data type. For example:
SELECT Time-as-number AS PI_TIMESTAMP, Value AS PI_VALUE, 0 AS PI_STATUS
FROM Table
WHERE (to_date('01-Jan-1970') + Time-as-number/(24*3600)) > ?; P1=TS
When the value is cast to a time stamp, any milliseconds in the numeric time stamp are
truncated in the resulting time stamp.
• If result rows contain multiple values and no target tag names, use tag groups.
• If result rows contain a single time stamp, tag name, and value, use distribution.
• If result rows contain multiple values and tag names, use RxC
For distribution and RxC, you define a distributor tag, which executes a query that retrieves
values to be written to target tags but does not receive any retrieved value itself. The
distributor tag must have a string or numeric data type (Float16, Float32, Float64, Int16,
Int32), and its time stamp is always the current time. After its query is executed and the results
are distributed to target tags, the distributor tag is updated with two events indicating the
results of the operation:
The time stamp is optional; if omitted, the interface uses the time of query execution. Status is
required, and can either be retrieved from the RDBMS or specified as a literal. For example:
SELECT Value, 0 FROM Table…
Result columns must be specified in "timestamp, value, status" order or aliased using the
following "PI_" alias keywords: PI_TIMESTAMP, PI_VALUE, PI_STATUS, PI_ANNOTATION.
For example:
SELECT Value AS PI_VALUE, Status AS PI_STATUS, Timestamp AS PI_TIMESTAMP,
Annotation AS PI_ANNOTATION FROM …
• Location2: To process only the first row returned by the query, set Location2 to 0. To
process all rows returned by the query, set Location2 to 1.
• Location3: Set to 2 if the first column returned by the query is a time stamp; otherwise set
to 1.
• Placeholders: In the ExDesc field of the master tag, define the placeholders required by the
query.
To specify the value to be assigned to the tag, set each tag’s Location3 attribute to the ordinal
number of the column returned by the query. For example, define a query that returns the
following columns:
Timestamp Value1 Status1 Value2 Status2
To update Tag1 with the first value and status and Tag2 with the second value and status,
configure the tags as follows:
In the query, each value column must be followed by its associated status. If the RDBMS
table does not contain status columns, you can specify the status as a literal (SELECT
Timestamp, Value1, 0 as Status1…).
2. In each target tag, set its attributes as follows:
◦ InstrumentTag: Path and name of query file. (Must be the same in all tags in the group.)
◦ Location3: Column number from which value is to be read. (Specify 2 for Tag1, and 4 for
Tag2.)
◦ ExDesc: In the ExDesc attribute of one of the target tags, specify the placeholders used
in the query (P1=TS).
You can also map result columns to tags by specifying aliases in the query, which enables you to
order the result columns without maintaining a strict positional correspondence with the value
you specify in Location3. The aliases end in a numeric value that corresponds to the value you
specify in Location3, but the result column can appear in any position in the query. You can
specify the following aliases (where n indicates the numeric value in Location3:
• PI_VALUEn
• PI_STATUSn
• PI_ANNOTATIONn
• PI_TIMESTAMPn (use when each value in the result table has its own timestamp column)
For example, in the following query, VALUE2 appears before VALUE1. Aliases are used to ensure
that each is assigned to the correct PI tag:
SELECT PI_TIMESTAMP, VALUE2 AS PI_VALUE2, VALUE1 AS PI_VALUE1, 0 AS PI_STATUS1,
0 AS PI_STATUS2 FROM T3_3 WHERE PI_TIMESTAMP > ? ORDER BY PI_TIMESTAMP ASC;
The following query updates the target tag specified in the TagName column:
SELECT Timestamp, TagName, Value, Status FROM Table
WHERE Timestamp > ?;
If the tag name stored in the RDBMS does not match the name of the target tag in the PI
System, you can map them by specifying the /ALIAS flag in the ExtendedDescriptor attribute of
the target tag. For example, if the result row contains "Tank1" in its "Device" column and you
want to store the data from the row in a PI point named "Unit10_Tank01," specify /
ALIAS="Tank1". Note that tag name comparisons are not case-sensitive, but aliases are case-
sensitive.
Distributor and target tags must be in the same scan class unless you specify an alias (using
the /ALIAS parameters), in which case the target tag can be assigned to a scan class different
from that of the distributor tag. If the distributor tag is event-based, the scan class ( Location4 )
of all target tags must be set to 0.
After the query is executed, the interface sends two events to the distributor tag:
• The number of events successfully distributed to target tags
• The number of rows in the result set
Both entries are time stamped with the current time; that is, both events appear in the PI
archive with the same time stamp.
Note:
To refer to tags with points sources other than the one specified for the RDBMS interface
instance, use PI ICU to enable the Distribute Outside Point Source option on the rdodbc >
Optional Parameters tab.
WHILE @ROWS_DROPPED
INSERT INTO Table2 (Name, Time, Value)
VALUES (?,?,?) LOOP; P1=AT.TAG P2=TS P3=VL
Note:
The @rows_dropped variable is supported only for tag distribution.
Multi-value rows might contain a different time stamp for each target tag; for example:
Timestamp1,Name1,Value1,Status1,Timestamp2,Name2,Value2,Status2,…
To distribute the data from such rows to the target tags, you define an RxC distributor tag,
setting its Location3 attribute to -2, and define the required SQL query using positional
aliases for result columns (PI_TIMESTAMPn, PI_TAGNAMEn, PI_VALUEn, PI_STATUSn,
PI_ANNOTATIONn). If the result row contains only one time stamp, use PI_TIMESTAMP.
Distributor and target tags must be in the same scan class unless you specify an alias (using
the /ALIAS parameters).
After the query is executed, the interface sends two events to the distributor tag:
The following example query returns a result row that can be distributed to target tags that
track level, temperature and density for individual tanks:
SELECT sampletime AS PI_TIMESTAMP1, 'Tag1' AS PI_TAGNAME1, [level] AS PI_VALUE1,
0 as PI_STATUS1,
sampletime AS PI_TIMESTAMP2, 'Tag2' AS PI_TAGNAME2, temperature AS PI_VALUE2,
temperature_status AS PI_STATUS2,
sampletime AS PI_TIMESTAMP3,'Tag3' AS PI_TAGNAME3, density AS PI_VALUE3,
density_status AS PI_STATUS3
FROM TestTable
WHERE sampletime > ? AND tank = 'Tank1';
Note:
To configure the interface to ignore NULLs for the tag group and RxC strategies, go to the
PI IUC rdbodbc > Optional Parameters tab and check Ignore Nulls.
a. To ensure that test data is generated rapidly, launch PI ICU on the PI Server and set scan
class 1 of the Random interface to a frequency of five seconds.
b. In your target relational database, create a table called "sinusoid-out" containing the
following columns:
Column Name SQL Data Type
your_timestamp DATETIME
your_value FLOAT
your_status INT
c. Launch PI System Management Tools, choose Points > PI Point Builder, and define a point
called "SINUSOID_TO_RDBMS". Configure its settings as follows:
ICU Tab Field Setting
PointSource RDBMSPI (or whatever setting
you configured for the
interface instance when you
defined it)
ExDesc /SQL="INSERT INTO
sinusoid-out
(your_timestamp,
your_value, your_status)
VALUES (?,?,?);" P1=TS
P2=VL P3=SS_I
SourceTag SINUSOID
Archive Compressing Off
ExcDev 0
Start the RDBMS interface and check the log output to verify that your output tag is
properly defined. If there are no errors in the point definition, check the RDBMS to verify
that values are being written to the sinusoid-out table.
• Writing multiple PI values to a single row
If your RDBMS table stores values from different points in a single row, define an INSERT
query that assigns the values using the 'tagname'/VL placeholder. For example, the
following query writes values from three different PI Random Simulator interface tags to
the same database row:
INSERT INTO multicol (timestamp, val1, val2, val3, status)
VALUES (?,?,?,?,?); P1=TS P2=VL P3='SINUSOIDU'/VL
P4='CDT158'/VL P5=SS_I
The query must include start and end time placeholders (TS and TE). The placeholders are
resolved at run time to the start time and end time that you specify when you run the interface
in recovery mode. You specify start and end time using PI ICU, on the rdbodbc > Recovery
Parameters tab, as shown in the following figure.
Specify recovery start and end time as an absolute time (for example, 01-Jan-2000) or a
relative time (for example, *-8h), or specify the name of a PI time stamp tag that contains the
start or end time. For details about specifying time in the PI System, refer to the Data Archive
Manual. If you omit the end time, the interface performs recovery and then begins real-time
data collection. If you specify end time, the interface recovers data and then exits.
Note:
Regardless of whether UTC handling is enabled, you must specify the start and end times
in PI time format, not UTC.
To mitigate the server workload when recovering large amounts of data , specify Input
Recovery Step, which configures the size of the increments in which the interface reads data
from the PI Server.
To recover data, start the interface using PI ICU. To view the messages issued by the interface
during recovery, display the log in the Log subdirectory of the interface installation directory.
After recovery, check the target PI Server to verify that the desired data has been recovered.
For example, the following figure shows how recovery proceeds if you specify a start time of
March 25, 2013 at 1:50 PM, an end time of March 25, 2013 at 1:50:20 PM, and a step size of 10
seconds. The query is as follows:
SELECT Timestamp,Value,0 FROM Table
WHERE Timestamp >= ? AND Timestamp < ?
ORDER BY Timestamp; P1=TS P2=TE
• Set its Location5 attribute to the desired option for recovering out-of-order data. For
details, see Recovering out-of-order data.
• Set the SourceTag attribute to the name of the PI tag from which archive data is to be read.
• Specify the query and placeholder definitions in the tag’s Exdesc attribute or store the
query in a text file, specifying the query file name in the tag’s InstrumentTag attribute and
defining the placeholders in the tag’s Exdesc attribute
For example, the following simple INSERT query, specified in full in the tag’s ExDesc attribute,
updates the RDBMS with values and time stamps from the archive for the specified source tag:
/SQL="INSERT INTO SINUS_OUTPUT VALUES (?,?);" P1=TS P2=VL
By default, placeholder data for scanned output tags comes from the tag itself and placeholder
data for triggered output tags comes from the source tag, unless the placeholder includes a
'tagname’' argument.
Following is an example of a query that specifies logic for each type of event.
IF @SOURCE_APPENDED
INSERT INTO RDBMSPI_Table_1 (tag, timestamp, value)
VALUES (?,?,?);
IF @SOURCE_REPLACED
UPDATE RDBMSPI_Table_1 SET Tag=?, Value=?
WHERE Tag=? AND Timestamp=?;
IF @SOURCE_REMOVED DELETE RDBMSPI_Table_1
WHERE Tag=? AND Timestamp=?;
Placeholder definitions:
P1=AT.TAG P2=TS P3=VL P4=P1 P5=P3 P6=P1 P7=P2 P8=P1 P9=P2
In the following figure, a SINUSOID event in the PI Archive was changed to Bad Input (-255),
so the interface executes the UPDATE query specified in the @SOURCE_REPLACEDclause
• Recover End Time: Specify the end of the period to be recovered. If you omit end time, the
interface recovers data from the specified start time to the present time and then starts
normal data collection. If you specify an end time, the interface recovers data and then exits.
• Input Recovery Step: To control memory consumption, specify the timespan to be
processed as a chunk. The default step size is one day (1d). (Input recovery only)
Recovery start and end times can be specified as either absolute or relative times, and you
must use the same format for both start and end time; in other words, you cannot specify a
relative start time with an absolute end time. To specify an absolute time, use the following
format:
start [, end]
Where the start and end time stamps are specified in the following format:
DD-MMM-YY hh:mm:ss
If you omit end time, all data up to the present is recovered. (Default end time = "*")
To specify a relative time, use the following format:
[+ | -] #units
• y: years
• mo: months
• w: weeks
• d: days
• h: hours
• m: minutes
• s: seconds
• t: today at midnight (00:00:00)
• *: now (current date and time)
To configure Input Recovery Step, specify units using the #units syntax. For example, to
recover one week at a time, specify 1w. Following are examples of recovery time specifications.
Recovery start time Recovery end time Input recovery step Description
01-Jan-00 None specified 30d Absolute start time:
recovery starts with data
time stamped Jan 1, 2000
and continues to the
present time. Data is
processed in 30-day
chunks.
01-Jan-00 01-Jan-09 30d Absolute start and end
times: data from Jan 1, 2000
through Jan 1, 2009 is
recovered in 30-day chunks.
*-365d None specified 1d Relative start time: data for
the last year is recovered.
Recovery start time Recovery end time Input recovery step Description
*-365d *-1h 1d Relative start time, relative
end time: data for the last
year is recovered, stopping
an hour before the current
time.
RecoveryStart RecoveryEnd 24h Name of the time stamp
tags: the snapshot value of
the tags is used as the start
and end time. The tag must
be a time stamp tag. Data is
recovered in 24-hour
chunks.
As an alternative to specifying an absolute or relative time, you can specify the name of a PI
time stamp tag. The snapshot value of the tag is used for the start or end time.
Note:
If you are running the interface against PI Servers with high availability features, and PI
SDK buffering is not enabled, SQL queries containing PI annotations bypass exception
reporting and deliver events to the primary PI Server.
Feature Support
Auto Creates PI Points No
Point Builder Utility No
ICU Control Yes
PI Point Types Float16 / Float32 / Float64 / Int16 / Int32 /
Digital / String / Timestamp
Sub-second Timestamps Yes
Sub-second Scan Classes Yes
Automatically Incorporates PIPoint Attribute Yes
Changes
Exception Reporting Yes
Outputs from PI Yes (event-based and scan-based)
Feature Support
Inputs to PI Scan-based, unsolicited, and event points
Questionable Bit Support No
PI Annotations Support Yes
Multi-character PointSource Yes
Maximum Point Count Unlimited
Required PI API Version 1.6.0+
Uses PI SDK Yes ( to access annotations and some point
attributes)
PINet String Support No
Source of Time stamps RDBMS or PI Server, depending on how you define
the query that updates the target.
History Recovery Yes
UniInt-based Yes
Disconnected Startup No
SetDeviceStatus Yes
Failover UniInt Phase 2 Failover (cold); RDBMS Server-level
failover for Microsoft SQL Server only
Vendor Software Required on PI Interface Node / Yes
PINet Node
Vendor Software Required on Foreign Device Yes
Vendor Hardware Required No
Additional PI Software Included with Interface No
Device Point Types See note below.
Serial-Based Interface No
For information on how to configure health points, refer to the UniInt Interface User Guide.
History Recovery
For output points, the interface reads historical data from the PI Archive. For input points,
history recovery depends on the WHERE condition of the associated SELECT query.
Interface Failover
This interface supports UniInt phase 2 cold failover. For details about configuring interface
failover, consult the UniInt Interface User Manual. Unlike data sources that emit real-time data,
data in an RDBMS is usually persistent. As a result, configuring interface failover is less likely to
be critical (unless the data in your RDBMS is volatile and it's essential to historize it in real
time). If the interface fails, you can restart it and it will recover data from the downtime.
Prerequisites
• PI Prerequisites
• PI Interface Configuration Tool (ICU)
Procedure
1. Install the RDBMS interface on the interface node.
2. Launch the ICU and configure a new instance of this interface. Essential startup parameters
for this interface are:
◦ Point source
◦ Interface ID
◦ PI Server
◦ Scan class
◦ Data source name (source/target ODBC data source name)
◦ Interface log file
3. Start the interface interactively and verify that it can connect to the PI Server and the
RDBMS.
4. Stop the interface and configure a buffering application. To optimize buffering throughput,
sert the primary and secondary memory buffer size to 2000000. (In PI ICU, choose Tools >
Buffering… and go to the Buffering Settings page.)
5. Start the buffering application and the interface. Confirm that buffering works by
disconnecting the interface node from the PI Server or by stopping the PI Server.
6. Configure the interface to run as a Windows Service. Confirm that the service runs properly.
7. Restart the interface node and confirm that the interface and the buffering services start.
Procedure
1. Build input tags and, if desired, output tags for this interface. Important point attributes and
their purposes are:
◦ Location1: Interface instance ID
◦ Location2: Bulk or non-bulk reading
◦ Location3: Data acquisition strategy
◦ Location4: Scan class
◦ Location5: Specifies how the data is sent to PI (snapshot, archive write, etc).
◦ ExDesc: Parameters and placeholders for SQL queries
◦ InstrumentTag: The name of the file that stores the SQL file.
◦ SourceTag: Trigger tag for output tags.
2. Test the connection between the interface node and the RDBMS using an application such as
Microsoft® ODBC Test.
3. Define the queries required to update the RDBMS or PI points according to your
requirements. Verify that the SQL queries are syntactically correct and return data as
expected.
4. Configure a test tag to use a query as described in this guide, and verify that data is read or
written as expected.
Procedure
1. Configure scan class performance points.
2. Install the full version of the PI Performance Monitor Interface on an interface node.
3. Configure performance counter points.
4. Configure UniInt health monitoring points
5. Configure the I/O rate point.
6. Configure the interface status point.
A yellow field indicates that an invalid value has been entered, or that a required value has not
been entered.
DSN Settings
Field Description
DSN Data Source Name (/DSN) Required
Username Username for access to RDBMS (/USER_ODBC)
Required
Password Password for access to RDBMS (/PASS_ODBC). The
password is encrypted and stored locally in the
directory configured for interface log files (/
OUTPUT). To enter a new password, click .
• Recovery Mode
Enable/disable recovery mode.
• Input Processing
Field Description
Recovery Start Time Specifies the point in time at which recovery
begins. Can be an absolute time, a relative time,
or the name of a PI timestamp tag. (/
RECOVERY_TIME)
Recovery End Time Specifies the point in time at which recovery
ends. Can be an absolute time, a relative time, or
the name of a PI timestamp tag. (/
RECOVERY_TIME)
Input Recovery Step Specifies the size of chunk in which data is read
during recovery, to avoid taxing system
resources.
• Output Processing
Field Description
Recovery Start Time Specifies the point in time at which recovery
begins. (/RECOVERY_TIME)
Recovery End Time Specifies the point in time at which recovery
ends.(/RECOVERY_TIME)
Out of Order Options Specifies how out-of-order data is to be handled,
for tags with Location5 set to 1. (OOO_OPTIONS)
Field Description
Write Size Cache (# of Events) When laboratory caching is enabled (/LB),
specifies the maximum number of values written
in one (bulk) call to the PI Archive; default is
10240 events per bulk. This parameter can be used
to tune (throttle) the load on the PI Server. (/
WS=#, Default: 10240, Optional)
Write Delay (milliseconds) When laboratory caching is enabled (/LB),
specifies the write delay (in milliseconds) between
bulk writes to the PI archive. Default is 10ms. Used
to tune the load on the PI System and the network.
(/WD=#, Default: 10, Optional)
Field Description
Maximum Log (# of Files) Maximum number of log files in the circular buffer.
The interface starts overwriting the oldest log files
when the MAXLOG has been reached. By default,
log files are never overwritten. (/MaxLog=#,
Optional)
Maximum Log File Size (mb) Maximum size of the log file in MB. If this
parameter is omitted, the default maximum is 20
MB. (/MaxLogSize=#, Default: 20, Optional)
Consecutive Errors to Reconnect Number of consecutive errors that causes the
interface to deallocate all ODBC statements and
attempt to reconnect to the RDBMS. (/ERC=#,
Optional)
Failover Timeout (seconds) Specifies how long to wait for query results to
return before failing over to the secondary RDBMS
server. (/Failover_Timeout=#, Optional)
Direct SQL Execution All SQL statements are prepared, bound and
executed each time they are scheduled for
execution. By default, statements are prepared and
bound only once, before the first execution. (/
ExecDirect, Optional)
Laboratory Caching Bulk-write events directly to PI Archive. When this
option is enabled, the Location5 setting is ignored.
Event handling is faster when this option is
enabled, and archive mode is ARCREPLACE. (/lb,
Optional)
Times are UTC Handle timestamps as UTC. If the timestamps in
the RDBMS are stored in UTC format, you must
enable this setting.(/UTC, Optional)
No Input Errors Disable writing of the BAD_INPUT, IO_TIMEOUT
digital states when an error occurs. (/
NO_INPUT_ERROR, Optional)
Read Before Overwrite Check the archive to see if value already exists at
the same timestamp. If so, do not overwrite with
new value. Affects only points with Location5=1. (/
RBO, Optional)
Exit Before Reconnect Exit if connection error occurs. By default, the
interface tries to reconnect. (/EBR, Optional)
Distribute Outside Point Source Enable interface to update points with point
source other than the one configured for the
interface instance. (/DOPS, Optional)
Ignore Nulls Ignore events retrieved from the RDBMS if value is
NULL.Prevents writing of the "No Data" system
digital state for tag group and RxC distributions
when the value column is NULL. (/Ignore_Nulls,
Optional)
Scan Class – I/O Rate Tag fields Configure an I/O rate tag and assign a scan class to
it. (/TF, Optional)
Field Description
Debug Settings Specifies level of detail to be logged. (/DEB)
Additional Parameters This section is provided for any additional
parameters that the ICU does not explicitly
support.
/Global= FilePath Specify the file that contains the definitions of the
global variables. (Optional)
(Optional)
Oracle
The caveats in this section are known to apply to Oracle7.0; Oracle 8.x, 9i, 10g, 11g; and Oracle
RDB.
The limit can also be exceeded by cursors that are opened in stored procedures.
You can increase this limit for your Oracle server by editing the INIT.ORA file and setting
OPEN_CURSORS. However, this is a server-level configuration change, so undertake it with
care. As an alternative, consider the following approaches:
◦ Oracle RDB
SELECT timestamp,value,status FROM Table LIMIT TO 10 ROWS;
SELECT timestamp,value,status FROM Table LIMIT TO 10 ROWS
WHERE timestamp > ? ORDER BY timestamp;
◦ Oracle 8.0 (NT) and above
SELECT timestamp,value,status FROM Table WHERE ROWNUM<11;
• Returning results from stored procedures
To create a stored procedure that returns results, you must create the stored procedure and
a package, as follows:
Example:
CREATE PROCEDURE sp_RDBMSPI1
(@name varchar(30), -- tag name
@TS datetime -- timestamp)
AS
SET NOCOUNT ON
INSERT Table1 VALUES(@name,@TS)
SELECT Timestamp,Value,0 FROM Table2
WHERE Tagname = @name and Timestamp > @TS
1. Store the SQL queries in a text file directory that is configured for SQL files on the PI ICU
rdbodbc > Startup Parameters tab.
2. Create the PI points, setting example-specific attributes as described in the example.
3. Create the RDBMS table as specified and, if needed, populate the table with sample data.
For all points in these examples, the following settings are standard:
Point attribute Description
Location1 Interface instance ID
Location4 Scan class
InstrumentTag Name of query file
PointSource Matches point source configured for interface
instance
In the examples, note that the name of SQL query files, RDBMS tables and table columns is up
to you. User-defined names are italicized.
If the query returns two rows containing (10, 20, 30) and (11, 21, 31), the following table
shows how the values are assigned to the target points.
PI_TIMESTAMP PI_VALUE1 to PI_VALUE2 to PI_VALUE3 to
Target_Point1 Target_Point2 Target_Point3
20-Oct-2000 08:10:00 10 20 30
20-Oct-2000 08:20:00 11 21 31
Given this result set, the interface assigns values to PI points as follows:
Point Value assigned
Target_Point1 10
Target_Point2 20
Target_Point3 30
Use this option when the length of the settings in the ExDesc attribute exceeds 1024
characters.
INSERT INTO your_table (PI_TAGNAME1, PI_TIMESTAMP1, PI_VALUE1, PI_STATUS1,
PI_TAGNAME2, PI_VALUE2, PI_STATUS2) VALUES (?,?,?,?,?,?,?);
example, VALUE1 is column 2 and VALUE2 is column 4. The contents of VALUE1 are written to
Target_Point1 and the contents of VALUE2 are written to Target_Point2.
SELECT your_time AS PI_TIME, your_value1 AS PI_VALUE1, 0 AS PI_STATUS1,
your_value2 AS PI_VALUE2, 0 AS PI_STATUS2
FROM your_table
WHERE PI_TIME > ?;
Example data:
PI_TIME PI_TAGNAME PI_VALUE
20-Oct-2000 08:10:00 Tag1 4.567
20-Oct-2000 08:10:10 Tag2 5.568
20-Oct-2000 08:10:20 Tag3 6.569
target tag. In the following example, data for the PI tag named "Tag2" is stored in RDBMS rows
that refer to "Valve1," and so on.
SELECT your_time AS PI_TIME, your_alias AS PI_ALIAS, your_value AS PI_VALUE, 0
AS PI_STATUS
FROM your_table
WHERE PI_TIME > ?;
Example data:
Time PI_Alias Value
20-Oct-2000 08:10:00 Valve1 "Open"
20-Oct-2000 08:10:00 Valve2 "Closed"
20-Oct-2000 08:10:00 Valve3 "N/A"
MINUTE(PI_INSERT_UPDATE.PI_TSTAMP)}
SET PI_INSERT_UPDATE.PI_TSTAMP = PI_INSERT_UPDATE_1ROW.PI_TSTAMP,
PI_INSERT_UPDATE.PI_VALUE = PI_INSERT_UPDATE_1ROW.PI_VALUE,
PI_INSERT_UPDATE.PI_STATUS = PI_INSERT_UPDATE_1ROW.PI_STATUS;
The interface stores the number of executed queries into the managing tag. In the short
form, nothing is stored when a point was edited and no real attribute change has been
made.
By default, the interface checks for attribute changes every two minutes. If an attribute is
changed twice within two minutes ending with its original value, the interface will NOT
record this; the interface misses the first change. Since RDBMSPI 3.11, the two-minute
interval can be changed by specifying the start-up parameter /UPDATEINTERVAL
• Long form configuration
Location4=-2 indicates that all AT.* placeholders can be employed. In this mode, the
interface does not remember what the previous attribute value was and forwards the
current PI point attributes state to RDB. The overall principles are the same as with the
short form. That is, any attribute change recognized by the interface is the trigger for the
SQL statement (INSERT) execution. The interface stores the number of executed queries
into the managing tag.