Interaction with Relational Databases
Bodo Bachmann, Gregg Le Blanc
PRESENTATION OVERVIEW
• Available options to connect to RDBMS’s
5min
• New version of PI-ODBC
5min, detailed list of new features, demo here or below, Gregg
• From PI-ODBC via ADO/RDS to the Web
10min, r/w example showing support of new data types and
UPDATE/INSERT, Gregg
• PI-OLEDB prototype
10min, demo MMC snap-in, PB DataControl/DataGrid, Bodo
• PI RDBMS Interface
10min, demo point configuration log, edit Tags via MS Query, log in
Access, Bodo
• Questions
5min
PI-API
PI-ProcessBOOK &
PI-PC DATALINK
(EXCEL, LOTUS 123)
RDBMS ODBC
RDBMS NET
PI-ODBC
PI-OLE DB
OTHER PC TOOLS
(POWER BUILDER, ACCESS,
VISUAL BASIC, Q+E, EXCEL,…)
RDBMS ODBC
RDBMS NET
ActiveX
RDBMS NET
RELATIONAL DATABASE
(RDBMS)
NON REAL-TIME DATA
PRODUCT, EQUIPMENT,
SPECIFICATION, SAFETY, ETC.
PI SERVER
PI SYSTEM
REAL-TIME DATA
MANUAL / PROCESS /
CALCULATED
RDBMS
INTERFACE
ODBC
OLE DB
COM
CONNECTOR
MANUAL / LAB
INPUTS
AUTOMATIC SCANNED DATA
TEXT / DATA / CONFIG
MANY OPTIONS...
ProcessBook and RDBMS’s
• Embedded ODBC support (DataSet)
• ActiveX Data Controls
• ADO via VBA
• Other Libraries via VBA (OLE DB, RDS,...)
• Special developped ProcessBook AddIn
• PI-UDA Tags via OLE DB Com Connector
PI-API
PI-ProcessBOOK
RDBMS ODBC
RDBMS NET
ODBC
OLE DB
• Present PI Data as it would be a RDBMS
• Link PI tables into MS Access and use
MS Access as Report Writer
• Use OLE DB Gateway and link into
MS SQL Server 7
• Use ODBC Clients for Data Analysis,...
• New Version PI-ODBC 1.1.8:
•Support PI3 data types and milliseconds
•Read/Write access for data archive
PI-ODBC
PI-ODBC
OTHER PC TOOLS
(POWER BUILDER, ACCESS,
VISUAL BASIC, Q+E, EXCEL,…)
RDBMS ODBC
RDBMS NET
PI-ODBC and You
Gaining Wealth and Wisdom Through
PI-ODBC and the Web
ADO and Recordsets
• ActiveX data objects (ADO)
• Use ADO to:
– Create connections
– Execute queries
– Populate Recordsets
• Use Recordsets to:
– Present data
– Manipulate query results
Serving Data Using ASP’s
• Use IIS and Active Server Pages
– Written in HTML and VBScript
– Database access is on server side
• Install PI-ODBC on web server
• Configure and name system DSN
Grabbing Data
• Open the connection & recordset:
– Set Conn = Server.CreateObject(“ADODB.Connection”)
– Conn.Open “PI”
– Set Rs = CreateObject(“ADODB.RecordSet”)
– Set Rs = Conn.Execute(strQry)
• Retrieve Values:
SELECT Time, currentstat=DIGSTRING(status), Value, Tag
FROM picomp WHERE Tag = “Sinusoid”
AND Time >= DATE(“17-Mar-00 11:00”);
• Input Values:
INSERT INTO picomp (tag, time, value)
VALUES (“Sinusoid”, “*”, 42);
Applications
• Lab data entry.
• Query PI data via a web site.
• An example:
– Uses any web browser.
– Uses standard web building tools.
– Does not compromise security.
– All processing done on server side.
• Display recordset contents: <%=Rs(“value”)%>.
Demonstration
• Sample lab data entry page.
– Regular tags.
– String tags.
• Uses standard HTML forms.
• VBScript uses common operations:
– Do… Loop
– If… Then
– ADO etc.
Summary
• Use IIS and PI-ODBC to make simple
pages that use PI data.
• Results are browser independent.
• Can be effective as a lab entry terminal.
• PI-ODBC now supports string tags.
OLE DB - THE NEXT ODBC GENERATION
• OLE DB is based on COM
• OLE DB defines an open and extensible set of OLE interfaces
• OLE DB provides uniform access to tabular data, not limited to
RDB’s
• Rowset Interface and optional Command Interface
• OLE DB is the native communication technology for
MS SQL Server 7
• Via OLE DB, MS SQL Server 7 can link foreign tables, as MS Access
can do for ODBC data sources
• Less sophisticated data applications (non SQL) can become data
providers
e.g. Spreadsheets. E-Mail, Directory Services..
CONNECTIVITY
Spread-
sheet
ODBC
SQL ISAM Spatial File
OLE DB
OLE DB
Cursor
Engine
Dist. Query
Engine
Rel. Query
Engine
Active X Data Objects (ADO)
Application or Tool
Consumer
Services
Data
Providers
COM
/
DCOM
Microsoft
Transaction
Server
PI-OLEDB PROTOTYPE
ONE OF MANY POSSIBLE IMPLEMENTATIONS
• One can think of many ways to implement a PI- OLEDB driver
• We have chosen to build the prototype on top of PI-SDK
• This complements PI-API and PI-ODBC functionality
• PI-SDK functionality is available for non-programmers
• PI-SDK uses the same technology, COM
PI Server
Real Time Data
NT, UNIX, VMS
PI-SDK
PI-OLEDB
PI-SDK
PI-OLEDB
FUNCTIONALITY OF PI-OLEDB PROTOTYPE
• Major PI Configuration Data is made available via catalogs
(databases)
• PIPOINT - all configured pointclasses appear as tables
• PIDS - all digital state tables, that are configured in PI, are tables
• PIUSER - one table that contains PI users defined
• PIGROUP - one table per group
• SQL Language supported via Command Interface
• CREATE and DROP tables
• UPDATE, INSERT, SELECT, DELETE
”SELECT * FROM PIPOINT:CLASSIC”
• Support for WHERE clause
“… WHERE TAG=’x*’ AND ARCHIVING=1 OR SCAN=0”
• Support for ORDER BY
SELECT * FROM CLASSIC ORDER BY CREATIONDATE DESC
BIG VARIETY OF ODBC CLIENTS CAN BE USED
• An ODBC Gateway makes OLE DB available for ODBC Clients
• We have successfully tested ISG Navigator
PI Server
Real Time Data
NT, UNIX, VMS
PI-SDK
PI-OLEDB
ODBC Gateway
(ISG Navigator)
ODBC Driver Manager
Client Applications
MS Access, MS Query,
Other ODBC Clients
SQL Calls
MS QUERY VIA ISG NAVIGATOR
PI-OLEDB and ADO
• ADO (ActiveX Data Objects ) is a programming interface that wraps
the OLE DB API
• ADO is easier to use than OLE DB, since more compact and fewer
objects
• ADO especially made for the VB/VBA environment
• Several Data Binding Controls allow data access without
programming
• Controls that encapsulate database queries and returned rowsets
are for example:
MS ADO DC, Apex True DataControl
• Data aware Grid Controls that bind to data controls are for example:
MS DataGrid Control, Apex True DBGrid Control
PI-OLEDB and Data Controls
• ADO DC + DataGrid Control + 3 Lines VBA = PI User Admin
• SnapIn for Microsoft Management Console (MMC)
LIMITATIONS OF PI-OLEDB PROTOTYPE
• Only configuration data (PI-SDK)
• Not for PI2 Systems (yet)
• SELECT … WHERE clause limited to specify fields which are
supported by PI-SDK query
• Command interface supports basic SQL, but no JOIN, UNION,...
and no Functions
• Performance slower than PI-ODBC
• Rewrite to use PI-SQLSS
Enhancements required for PI-SQLSS and PI-SDK
• Support for PI Module DB and PI Data Archive
• Performance optimisation
• Free-threaded version (linked tables for MS SQL Server 7)
• Next level SQL language
FUTURE DEVELOPMENT OF PI-OLEDB
PI-API
PI-ProcessBOOK &
PI-PC DATALINK
(EXCEL, LOTUS 123)
RDBMS ODBC
RDBMS NET
PI-ODBC
PI-OLE DB
OTHER PC TOOLS
(POWER BUILDER, ACCESS,
VISUAL BASIC, Q+E, EXCEL,…)
RDBMS ODBC
RDBMS NET
ActiveX
RDBMS NET
RELATIONAL DATABASE
(RDBMS)
NON REAL-TIME DATA
PRODUCT, EQUIPMENT,
SPECIFICATION, SAFETY, ETC.
PI SERVER
PI SYSTEM
REAL-TIME DATA
MANUAL / PROCESS /
CALCULATED
RDBMS
INTERFACE
ODBC
OLE DB
COM
CONNECTOR
MANUAL / LAB
INPUTS
AUTOMATIC SCANNED DATA
TEXT / DATA / CONFIG
PI RDBMS INTERFACE
PI RDBMS INTERFACE STRUCTURE
• Interface runs on Windows NT / 2000
• Works for ANY Relational Database
which has an ODBC driver
• Tested by OSI explicitly:
MS SQL Server 6.5/7, Oracle 7.1/8,
Oracle RDB 6.1, MS Access 95/97,
dBase III/IV
PI-API
RDBMS
INTERFACE
RDBMS ODBC
RDBMS NET
RDBMS NET
RELATIONAL DATABASE
(RDBMS)
NON REAL-TIME DATA
PRODUCT, EQUIPMENT,
SPECIFICATION, SAFETY, ETC.
PI SERVER
PI SYSTEM
REAL-TIME DATA
MANUAL / PROCESS /
CALCULATED
ODBC
OLE DB
• Query data (read) for single tag, tag groups and distributed tags
• Query one value or time series per scan
• Scan or Event based SELECT queries (PI Input)
• Event based UPDATE, DELETE and INSERT queries (PI Output)
• Support multiple statements per query and Stored Procedures
• Support of ‘runtime’ placeholders
• Support of classic ‘point attribute’ placeholders
• Support of ‘batch’ placeholders to replicate PI batch records
• Historize Tag Database changes in RDBMS tables
• Recovery for Output data after interface down
PI RDBMS INTERFACE FUNCTIONALITY
PI RDBMS INTERFACE
• Modify PI Tags via PI-OLEDB
• Historize changes automatically in RDBMS table
• Version 2.14 in Beta, bug fixes and DB2 tests
• Optional replacement of archive data
• Timezone handling when interface in different TZ than PI Server
• Version 3 development starts now
• Automate login configuration via connection dialog
• Overcome 80 char limit of Extended Descriptor
• Support all pointclass attributes for placeholder AT.ATTRIBUTE
• Tag configuration and ODBC testtool
• Scan based output
• Output of aggregate data (piar_calculation instead of sourcetag)
PI RDBMS INTERFACE - NEXT DEVELOPMENT
PI AND RDBMS’s

PI-RDBMS.ppt

  • 1.
    Interaction with RelationalDatabases Bodo Bachmann, Gregg Le Blanc
  • 2.
    PRESENTATION OVERVIEW • Availableoptions to connect to RDBMS’s 5min • New version of PI-ODBC 5min, detailed list of new features, demo here or below, Gregg • From PI-ODBC via ADO/RDS to the Web 10min, r/w example showing support of new data types and UPDATE/INSERT, Gregg • PI-OLEDB prototype 10min, demo MMC snap-in, PB DataControl/DataGrid, Bodo • PI RDBMS Interface 10min, demo point configuration log, edit Tags via MS Query, log in Access, Bodo • Questions 5min
  • 3.
    PI-API PI-ProcessBOOK & PI-PC DATALINK (EXCEL,LOTUS 123) RDBMS ODBC RDBMS NET PI-ODBC PI-OLE DB OTHER PC TOOLS (POWER BUILDER, ACCESS, VISUAL BASIC, Q+E, EXCEL,…) RDBMS ODBC RDBMS NET ActiveX RDBMS NET RELATIONAL DATABASE (RDBMS) NON REAL-TIME DATA PRODUCT, EQUIPMENT, SPECIFICATION, SAFETY, ETC. PI SERVER PI SYSTEM REAL-TIME DATA MANUAL / PROCESS / CALCULATED RDBMS INTERFACE ODBC OLE DB COM CONNECTOR MANUAL / LAB INPUTS AUTOMATIC SCANNED DATA TEXT / DATA / CONFIG MANY OPTIONS...
  • 4.
    ProcessBook and RDBMS’s •Embedded ODBC support (DataSet) • ActiveX Data Controls • ADO via VBA • Other Libraries via VBA (OLE DB, RDS,...) • Special developped ProcessBook AddIn • PI-UDA Tags via OLE DB Com Connector PI-API PI-ProcessBOOK RDBMS ODBC RDBMS NET ODBC OLE DB
  • 5.
    • Present PIData as it would be a RDBMS • Link PI tables into MS Access and use MS Access as Report Writer • Use OLE DB Gateway and link into MS SQL Server 7 • Use ODBC Clients for Data Analysis,... • New Version PI-ODBC 1.1.8: •Support PI3 data types and milliseconds •Read/Write access for data archive PI-ODBC PI-ODBC OTHER PC TOOLS (POWER BUILDER, ACCESS, VISUAL BASIC, Q+E, EXCEL,…) RDBMS ODBC RDBMS NET
  • 6.
    PI-ODBC and You GainingWealth and Wisdom Through PI-ODBC and the Web
  • 7.
    ADO and Recordsets •ActiveX data objects (ADO) • Use ADO to: – Create connections – Execute queries – Populate Recordsets • Use Recordsets to: – Present data – Manipulate query results
  • 8.
    Serving Data UsingASP’s • Use IIS and Active Server Pages – Written in HTML and VBScript – Database access is on server side • Install PI-ODBC on web server • Configure and name system DSN
  • 9.
    Grabbing Data • Openthe connection & recordset: – Set Conn = Server.CreateObject(“ADODB.Connection”) – Conn.Open “PI” – Set Rs = CreateObject(“ADODB.RecordSet”) – Set Rs = Conn.Execute(strQry) • Retrieve Values: SELECT Time, currentstat=DIGSTRING(status), Value, Tag FROM picomp WHERE Tag = “Sinusoid” AND Time >= DATE(“17-Mar-00 11:00”); • Input Values: INSERT INTO picomp (tag, time, value) VALUES (“Sinusoid”, “*”, 42);
  • 10.
    Applications • Lab dataentry. • Query PI data via a web site. • An example: – Uses any web browser. – Uses standard web building tools. – Does not compromise security. – All processing done on server side. • Display recordset contents: <%=Rs(“value”)%>.
  • 11.
    Demonstration • Sample labdata entry page. – Regular tags. – String tags. • Uses standard HTML forms. • VBScript uses common operations: – Do… Loop – If… Then – ADO etc.
  • 12.
    Summary • Use IISand PI-ODBC to make simple pages that use PI data. • Results are browser independent. • Can be effective as a lab entry terminal. • PI-ODBC now supports string tags.
  • 13.
    OLE DB -THE NEXT ODBC GENERATION • OLE DB is based on COM • OLE DB defines an open and extensible set of OLE interfaces • OLE DB provides uniform access to tabular data, not limited to RDB’s • Rowset Interface and optional Command Interface • OLE DB is the native communication technology for MS SQL Server 7 • Via OLE DB, MS SQL Server 7 can link foreign tables, as MS Access can do for ODBC data sources • Less sophisticated data applications (non SQL) can become data providers e.g. Spreadsheets. E-Mail, Directory Services..
  • 14.
    CONNECTIVITY Spread- sheet ODBC SQL ISAM SpatialFile OLE DB OLE DB Cursor Engine Dist. Query Engine Rel. Query Engine Active X Data Objects (ADO) Application or Tool Consumer Services Data Providers COM / DCOM Microsoft Transaction Server
  • 15.
    PI-OLEDB PROTOTYPE ONE OFMANY POSSIBLE IMPLEMENTATIONS • One can think of many ways to implement a PI- OLEDB driver • We have chosen to build the prototype on top of PI-SDK • This complements PI-API and PI-ODBC functionality • PI-SDK functionality is available for non-programmers • PI-SDK uses the same technology, COM PI Server Real Time Data NT, UNIX, VMS PI-SDK PI-OLEDB PI-SDK PI-OLEDB
  • 16.
    FUNCTIONALITY OF PI-OLEDBPROTOTYPE • Major PI Configuration Data is made available via catalogs (databases) • PIPOINT - all configured pointclasses appear as tables • PIDS - all digital state tables, that are configured in PI, are tables • PIUSER - one table that contains PI users defined • PIGROUP - one table per group • SQL Language supported via Command Interface • CREATE and DROP tables • UPDATE, INSERT, SELECT, DELETE ”SELECT * FROM PIPOINT:CLASSIC” • Support for WHERE clause “… WHERE TAG=’x*’ AND ARCHIVING=1 OR SCAN=0” • Support for ORDER BY SELECT * FROM CLASSIC ORDER BY CREATIONDATE DESC
  • 17.
    BIG VARIETY OFODBC CLIENTS CAN BE USED • An ODBC Gateway makes OLE DB available for ODBC Clients • We have successfully tested ISG Navigator PI Server Real Time Data NT, UNIX, VMS PI-SDK PI-OLEDB ODBC Gateway (ISG Navigator) ODBC Driver Manager Client Applications MS Access, MS Query, Other ODBC Clients SQL Calls
  • 18.
    MS QUERY VIAISG NAVIGATOR
  • 19.
    PI-OLEDB and ADO •ADO (ActiveX Data Objects ) is a programming interface that wraps the OLE DB API • ADO is easier to use than OLE DB, since more compact and fewer objects • ADO especially made for the VB/VBA environment • Several Data Binding Controls allow data access without programming • Controls that encapsulate database queries and returned rowsets are for example: MS ADO DC, Apex True DataControl • Data aware Grid Controls that bind to data controls are for example: MS DataGrid Control, Apex True DBGrid Control
  • 20.
    PI-OLEDB and DataControls • ADO DC + DataGrid Control + 3 Lines VBA = PI User Admin • SnapIn for Microsoft Management Console (MMC)
  • 21.
    LIMITATIONS OF PI-OLEDBPROTOTYPE • Only configuration data (PI-SDK) • Not for PI2 Systems (yet) • SELECT … WHERE clause limited to specify fields which are supported by PI-SDK query • Command interface supports basic SQL, but no JOIN, UNION,... and no Functions • Performance slower than PI-ODBC
  • 22.
    • Rewrite touse PI-SQLSS Enhancements required for PI-SQLSS and PI-SDK • Support for PI Module DB and PI Data Archive • Performance optimisation • Free-threaded version (linked tables for MS SQL Server 7) • Next level SQL language FUTURE DEVELOPMENT OF PI-OLEDB
  • 23.
    PI-API PI-ProcessBOOK & PI-PC DATALINK (EXCEL,LOTUS 123) RDBMS ODBC RDBMS NET PI-ODBC PI-OLE DB OTHER PC TOOLS (POWER BUILDER, ACCESS, VISUAL BASIC, Q+E, EXCEL,…) RDBMS ODBC RDBMS NET ActiveX RDBMS NET RELATIONAL DATABASE (RDBMS) NON REAL-TIME DATA PRODUCT, EQUIPMENT, SPECIFICATION, SAFETY, ETC. PI SERVER PI SYSTEM REAL-TIME DATA MANUAL / PROCESS / CALCULATED RDBMS INTERFACE ODBC OLE DB COM CONNECTOR MANUAL / LAB INPUTS AUTOMATIC SCANNED DATA TEXT / DATA / CONFIG PI RDBMS INTERFACE
  • 24.
    PI RDBMS INTERFACESTRUCTURE • Interface runs on Windows NT / 2000 • Works for ANY Relational Database which has an ODBC driver • Tested by OSI explicitly: MS SQL Server 6.5/7, Oracle 7.1/8, Oracle RDB 6.1, MS Access 95/97, dBase III/IV PI-API RDBMS INTERFACE RDBMS ODBC RDBMS NET RDBMS NET RELATIONAL DATABASE (RDBMS) NON REAL-TIME DATA PRODUCT, EQUIPMENT, SPECIFICATION, SAFETY, ETC. PI SERVER PI SYSTEM REAL-TIME DATA MANUAL / PROCESS / CALCULATED ODBC OLE DB
  • 25.
    • Query data(read) for single tag, tag groups and distributed tags • Query one value or time series per scan • Scan or Event based SELECT queries (PI Input) • Event based UPDATE, DELETE and INSERT queries (PI Output) • Support multiple statements per query and Stored Procedures • Support of ‘runtime’ placeholders • Support of classic ‘point attribute’ placeholders • Support of ‘batch’ placeholders to replicate PI batch records • Historize Tag Database changes in RDBMS tables • Recovery for Output data after interface down PI RDBMS INTERFACE FUNCTIONALITY
  • 26.
    PI RDBMS INTERFACE •Modify PI Tags via PI-OLEDB • Historize changes automatically in RDBMS table
  • 27.
    • Version 2.14in Beta, bug fixes and DB2 tests • Optional replacement of archive data • Timezone handling when interface in different TZ than PI Server • Version 3 development starts now • Automate login configuration via connection dialog • Overcome 80 char limit of Extended Descriptor • Support all pointclass attributes for placeholder AT.ATTRIBUTE • Tag configuration and ODBC testtool • Scan based output • Output of aggregate data (piar_calculation instead of sourcetag) PI RDBMS INTERFACE - NEXT DEVELOPMENT
  • 28.