Learn about SQL examples for PI Interface for RDBMS
- Last UpdatedAug 19, 2025
- 2 minute read
- PI System
- Interfaces
As detailed in the Learn how to specify SQL queries section, and particularly in the Learn about query execution topic, the SQL language that you use is determined by the underlying SQL database and the ODBC driver. SELECT, INSERT, UPDATE, DELETE and {CALL()} SQL statements are used to transfer data between Data Archive and an RDBMS interface.
You can combine the above listed statements, but there are certain restrictions depending on their use with input and output points, as detailed in the Learn how to specify SQL queries section.
You can also write whatever subqueries are supported by the underlying database. (You may want to refer to Microsoft ODBC Programmer's Reference.) There are no restrictions to writing subqueries within PI Interface for RDBMS.
The example suite below shows various approaches for transferring data between Data Archive and an RDBMS interface. Examples are illustrative and are not installed as part of the interface. To implement the examples, perform the following:
-
Store the SQL queries in a text file in a directory that is configured for SQL files on the PI ICU rdbodbc > Startup Parameters tab; alternatively, define the SQL queries in the ExtendedDescriptor of a PI tag.
-
Create the PI points, setting the example-specific attributes as described in the example.
-
For all points in these examples, the following settings apply:
Point attribute
Description
Location1
Interface instance ID
Location2
0: Processes only the first row
1: Processes all rows
Location3
Data distribution strategy:
0: Single
-1: Tag Distribution
-2: RxC (Row x Column)
Location4
Scan class number
Location5
0: Exception reporting is enabled
1: Exception reporting is turned off
2: Add events @ the same timestamp
3: For tag distribution and RxC - process only newer data
4: Enables the full sync mode
InstrumentTag
Name of the query file
PointSource
Matches point source configured for interface instance
SourcePoint
For output tags - name of the tag that triggers the execution if its snapshot value changed
-
Create the RDBMS table as specified and populate the table with sample data.
As shown in the examples, the names of the SQL query files, RDBMS tables, and table columns may be whatever you want.
Note: In some examples, the semantic meaning of columns in the SELECT list is predetermined and the interface assumes that the first column is a timestamp, that the second is a value, and that the third is status. If every column in the SELECT list is aliased using the set of the "PI_" keywords, the meaning of individual columns is determined according to these keywords.
Related Links
- Update a single tag with single value using static key matching
- Update a single tag with most recent values from database
- Update three tags from a single row (group distribution)
- Update tags from more rows in table since last scan (distribution by tagname)
- Update tags from more rows in table reading the last hour each scan (distribution by alias) with the /RBO startup parameter set
- Update tags from more rows in table considering just the newer timestamps since the last scan (distribution by alias) without the /RBO startup parameter set
- Update tags from more rows in table marking the already-read rows (distribution by alias)
- Update points from more rows and columns (RxC row by column distribution using aliases) with SELECT list columns renamed
- Single input with PI annotations
- Single input with questionable flag
- Event-based input
- Event-driven outputs to an RDBMS table
- Scan-based outputs to an RDBMS table
- Multi-statement query
- Stored procedure call
- Full synchronization of RDB time series to PI Data Archive