TopView SQL Configuration

Similar documents
How do I connect to Peachtree using ODBC/OLEDB?

Beijer Electronics Data Collector. Manual. English MAEN826B,

Mobile Forms Integrator

Table of Contents DATA MANAGEMENT TOOLS 4. IMPORT WIZARD 6 Setting Import File Format (Step 1) 7 Setting Source File Name (Step 2) 8

DataLogger Server Plug-in Help Kepware Technologies

MASSTRANSIT DATABASE ANALYSIS. Using Microsoft Excel And ODBC To Analyze MySQL Data

Objective 1: Familiarize yourself with basic database terms and definitions. Objective 2: Familiarize yourself with the Access environment.

Administration. Training Guide. Infinite Visions Enterprise Edition phone toll free fax

QW5 -QWSQLWizard Overview

USER S MANUAL. Unified Data Browser. Browser. Unified Data. smar. First in Fieldbus MAY / 06. Unified Data Browser VERSION 8 FOUNDATION

Lesson 1: Creating and formatting an Answers analysis

Purchase Order Processor

DataLogger PTC Inc. All Rights Reserved.

Application Note 0007 Using ReportBuilder with Schneider Electric ClearSCADA

Manual Physical Inventory Upload Created on 3/17/2017 7:37:00 AM

SelectSurveyASP Advanced User Manual

User Guide Product Design Version 1.7

Workspace Administrator Help File

Your comments and suggestions on the operation of this software are welcome. Please address them to:

Introduction to Microsoft Access 2016

In this tutorial we will discuss different options available in the Options tab in EMCO Network Inventory 4.x.

Exploring the Microsoft Access User Interface and Exploring Navicat and Sequel Pro, and refer to chapter 5 of The Data Journalist.

Installing Blank SiriusSQL Database 4.0

Chapter 2 Autodesk Asset Locator... 3

Crystal Reports. Overview. Contents. Differences between the Database menu in Crystal Reports 8.5 and 9

Doc. Version 1.0 Updated:

Using Components Directly from Your Company Database

ODBC Client Driver PTC Inc. All Rights Reserved.

JUN / 04 VERSION 7.1 FOUNDATION P V I E W G A L M E

The software shall provide the necessary tools to allow a user to create a Dashboard based on the queries created.

AppsAudit. User s Guide. Software Version 6.5.6

Senturus Analytics Connector. User Guide Cognos to Tableau Senturus, Inc. Page 1

MYOB ODBC Direct. Test Applications

Doc. Version 1.0 Updated:

01 Transaction Pro Importer version 6.0

REPORTING Copyright Framework Private Equity Investment Data Management Ltd

Enterprise Reporting -- APEX

Global Software, Inc.'s Database Manager User Manual. Version 14.6

CCRS Quick Start Guide for Program Administrators. September Bank Handlowy w Warszawie S.A.

Getting Started with the Web Client

IRA Basic Running Financial Reports

Imagine. Create. Discover. User Manual. TopLine Results Corporation

Your comments and suggestions on the operation of this software are welcome. Please address them to:

Xpert BI General

AppsAudit. User s Guide. Software Version 7.0

Perceptive Matching Engine

My Query Builder Function

Microsoft Access XP Queries. Student Manual

DataWorX. - DataWorX. smar. DataWorX. First in Fieldbus USER S MANUAL MAY / 06 VERSION 8 FOUNDATION

SharePoint AD Administration Tutorial for SharePoint 2007

STOP DROWNING IN DATA. START MAKING SENSE! An Introduction To SQLite Databases. (Data for this tutorial at

Publish Joomla! Article

Logi Ad Hoc Reporting System Administration Guide

Publish Joomla! Article

WIRELESS DATABASE VIEWER PLUS FOR POCKET PC PHONE: USER GUIDE PRODUCT VERSION: 1.5

OSR Composer 3.7 User Guide. Updated:

Alarms & Events Plug-In PTC Inc. All Rights Reserved.

Report Commander 2 User Guide

Setting Up the Encore Interface

About using Microsoft Query to retrieve external data

Access Intermediate

Connect Databases to AutoCAD with dbconnect Nate Bartley Test Development Engineer autodesk, inc.

4.6.5 Data Sync User Manual.

.txt - Exporting and Importing. Table of Contents

User's Guide c-treeace SQL Explorer

Use mail merge to create and print letters and other documents

TRAINING GUIDE. Lucity Imports and CCTV

The LENA Advanced Data Extractor (ADEX) User Guide Version 1.1.2

Access Intermediate

HP NonStop Data Transformation Engine ODBC Adapter Reference Guide

Application Note 0001 Using ReportBuilder with GE Proficy Historian

LUCITY SECURITY. This manual covers managing users, groups, and permissions for Lucity. Version: 2017r2

Data Exchange 3. The easy way to turn your data into valuable information. VERSION 3.0

Teiid Designer User Guide 7.5.0

User Guide. Product Design. Version 2.2.2

User Manual. DocKIT for SharePoint

Tivoli Management Solution for Microsoft SQL. Statistics Builder. Version 1.1

Oracle SQL. murach s. and PL/SQL TRAINING & REFERENCE. (Chapter 2)

Introduction to Qualtrics ITSC

Creating Dashboard. Version: 7.3

Importing to WIRED Contact From a Database File. Reference Guide

Getting started with Ms Access Getting Started. Primary Key Composite Key Foreign Key

MX OPC Server 5.0 Help Documentation

WORKFLOW BUILDER TM FOR MICROSOFT ACCESS

Style Report Enterprise Edition

Using the Control Panel

Visual Workflow Implementation Guide

Viewpoint Delivery Manual

Integration Services. Creating an ETL Solution with SSIS. Module Overview. Introduction to ETL with SSIS Implementing Data Flow

TRAVELTRAX DESKTOP REPORTING User Guide v6.5.3 June 13, 2013

IBM. Bulk Load Utilities Guide. IBM Emptoris Contract Management SaaS

Nexio G-Scribe Data Source Wizard

How to Import Part Numbers to Proman

eschoolplus+ Cognos Query Studio Training Guide Version 2.4

Linking Reports to your Database in Crystal Reports 2008

1 INTRODUCTION TO EASIK 2 TABLE OF CONTENTS

Beijer Electronics Data Collector. Manual. English MAEN826D,

APM Import Tool. Product Guide

RSView 32 Setup. Enabling the OPC Server By default, the RSView32 OPC Server is not enabled.

Creating a File DSN. 1) Go to Control Panel Administrative Tools Data Sources (ODBC) 2) Select the File DSN tab. 3) Click Add

Transcription:

TopView SQL Configuration Copyright 2013 EXELE Information Systems, Inc. EXELE Information Systems (585) 385-9740 Web: http://www.exele.com Support: support@exele.com Sales: sales@exele.com

Table of Contents Introduction... 4 About this Document... 4 Database Communication Requirements... 4 ODBC... 4 Requirements... 4 DSN (Data Source Name)... 4 OLEDB... 5 Requirements... 5 Definitions of TopView SQL Terms... 6 Database Alias... 6 Query... 6 Tag... 6 TopView SQL Tag to Database Layer... 6 Configuring TopView SQL... 8 Introduction... 8 Sample Database available... 8 Launching TopView SQL Configuration... 8 TopView SQL Configuration: Main Screen... 9 Configuring Databases... 10 Database List screen... 10 Database Alias Edit screen... 11 Connection type... 11 ODBC Connection Details... 12 DSN type (use System DSN s!)... 12 DSN... 12 Additional connection parameters... 13 OLEDB Connection Details... 14 UDL Files:... 15 OLEDB Provider... 15 Data Source... 15 Base connection string... 15 OLEDB Connection String Builder (wizard)... 16 Wizard Connection String... 17 Investigate connection strings online... 17 Final connection string... 18 Configuring Queries... 19 Query List screen... 20 Export/Import Queries... 20 Query Edit screen... 21 Select Query... 22 Referencing current time in SELECT... 22 Query Placeholders... 23 Naming returned columns... 23 Calling Stored Procedures... 24 Run Query... 24 Test results... 25 Min. Interval... 25 Description/Comments... 25 2

Configuring Tags... 26 Tag List screen... 26 Export/Import Tags... 27 Tag Edit Screen... 28 Description/Units... 28 Database and Query... 28 Run Query... 28 Query lookup filter... 29 Get first record, Where... 29 Tag value column... 29 Tag timestamp column... 29 Tag Value, Status, Timestamp Notes... 30 Value... 30 Timestamp of the Value... 30 Status of the Value... 30 Tag Search... 31 TopView SQL Examples... 33 Access Database... 33 Sample Access table... 33 Sample Access table columns... 33 Defining a Database Alias for the sample Access database... 34 ODBC... 34 OLEDB... 35 Defining a Query for the sample Access database... 37 Defining a Tag for the sample Access database... 38 Text file Database... 39 Copy the sample text file to c:\textfiles\... 39 Sample Text file... 39 Sample table columns... 40 Defining a Database Alias for the sample text file... 41 ODBC... 41 Defining a Query for the sample text file... 45 Defining a Tag for the sample text file... 46 3

Introduction About this Document This document will assist the user with the configuration of the TopView SQL Tag to Database layer required for the TopView SQL real-time Alarm and Notification Engine. The TopView SQL Tag to Database layer configuration allows the user to define the databases (relational databases, flat files, spreadsheets, ), queries, and query results (tags) to be monitored by TopView SQL. Once TopView SQL tags are defined, TopView can monitor the current tag values (query results) and perform th alarming and notification functions supported in all TopView versions. Please see the separate TopView help/documentation for details on the configuration and operation of TopView once the TopView SQL tags have been defined. Database Communication Requirements TopView SQL supports two technologies for communication to the underlying databases: ODBC and OLEDB ODBC Open Database Connectivity (ODBC) refers to a software API method for accessing database management systems (DBMS). ODBC was created to be independent of programming languages or operational systems and offers access to different database systems. Requirements To query a database through ODBC, an ODBC driver for the database must be installed on the TopView SQL computer. Some ODBC drivers are already installed on the TopView computer and may be used to access databases. If an ODBC driver for your database is not already installed, you may need to obtain the ODBC driver from the database vendor. DSN (Data Source Name) On Windows computers, the user can define one or more DSN s (Data Source Name). The ODBC DSN configuration tool is available through Control Panel on the TopView computer as well as the TopView SQL Configuration tool. Each DSN defines an ODBC connection to a database. The DSN is a user-selected name as well as the database connection details required to connect to the database. For example, the user may configure a DSN named MyDatabase that defines an ODBC connection to a SQL Server database. The details of the DSN will name the computer and database name, login details, and other required information required by SQL Server. If the DSN does not allow the user to provide the required details for connection (e.g username and password), TopView SQL allows the user to provide this information through an additional connection parameter string. DSNs can be defined as User or System. This designation defines the scope, or visibility, of the DSN to applications on the same computer. The user should create System DSN s for use by TopView SQL. 4

OLEDB OLEDB is an API designed by Microsoft for accessing different types of data stores in a uniform manner. It is a set of interfaces implemented using the Component Object Model (COM); it is otherwise unrelated to OLE. It was designed as a higher-level replacement for and successor to ODBC. Requirements To query a database through OLEDB, an OLEDB Provider for the database must be installed on the TopView computer. Some OLEDB Providers are already installed on the computer and can be used to access databases. If an OLEDB Provider for your database is not already installed, you may need to obtain the OLEDB Provider from the database vendor. OLEDB does not support the definition and configuration of databases through DSNs. Therefore, the configuration of an OLEDB database for use by TopView SQL will normally include the connection details required to connect to the OLEDB database. The one exception is using UDL files (see 5

OLEDB Connection Details on page 14 for more information). Definitions of TopView SQL Terms Database Alias A Database Alias is the definition of a database that can be accessed by TopView SQL. Each Database Alias includes Query Name: A user-given name for the Database Alias Connection type: ODBC or OLEDB connection type Connection details: for ODBC connections, the DSN name; for OLEDB connections, the connection string details including the OLEDB Provider name and data source OR a UDL file. A Query is an operation that extracts a result (called a recordset or datatable) from a database. A query consists of one of the following: 1. Search criteria expressed in a database language called SQL Example: SELECT tank_id, level FROM tankdata 2. Procedure name (e.g. SQL Server Stored Procedure) and procedure arguments Example: GetTankData T0001 The query result may contain one or more columns and rows of data. The results of a single Query can feed multiple Tags, therefore reducing the overhead of Query execution in TopView. Tag A Tag is a specific value returned from a query. Since the Query may contains multiple records (rows) and columns of data, the Tag definition specifies a lookup filter into the Query results for the Tag value, and optionally, the Tag timestamp. A Tag value may contain various types of data including numeric (float, integer), timestamps (dates and times), and string or character data. TopView SQL Tag to Database Layer TopView uses the concept of a tag or point to represent a data value (numeric, string, timestamp, ) that can be monitored by TopView for real-time alarming and notification. Using the TopView Configurator, the user selects the tags to monitor and can then configure alarm limits for each tag, notification settings, etc. The TopView SQL Tag to Database Layer provides tags that can be monitored by TopView. This layer configured using the TopView SQL Configuration tool. 6

7

Configuring TopView SQL Introduction Configuring TopView SQL involves configuration of 1. The Databases that will be accessed by TopView SQL 2. The Queries that can be executed against each Database 3. The Tags that define specific results from Queries TopView SQL provides a set of configuration screens that allow the user to configure the settings for Databases, Queries, and Tags. If the user needs to configure a large number of Queries or Tags, the Query and Tag properties can be exported to a spreadsheet for bulk editing. The changes can then be imported into TopView SQL. Sample Database available TopView SQL installs a sample Microsoft Access Database that can be used for testing purposes. For more information, see TopView SQL on page 33. Launching TopView SQL Configuration To launch the TopView SQL Configuration: 1. When the user launches the TopView Configurator, TopView will check for the existence of any defined Databases, Queries, and Tags. If none exist, the user will be prompted to start the TopView SQL Configuration utility. 2. From the TopView Configurator Verify that the current TopView Data Source is SQL by selecting SQL from the data source drop-down in the upper right corner of the Configurator Click Tags and Limits from the left menu of the Configurator Click Configure TopView SQL above the [Tag Search] button 8

TopView SQL Configuration: Main Screen The TopView SQL Configuration main screen lists number of defined Databases and the number of defined Tags. To configure or edit Databases and/or Queries, click Create/Edit Databases and Queries. See Configuring Databases on page 10. To configure or edit Tags, click Create/Edit Tags. See Configuring Tags on page 26. 9

Configuring Databases Each ODBC/OLEDB Database that can be accessed by TopView SQL is defined as a Database Alias. Each Database Alias contains a user-given name (the Database Alias name) the Database connection type (ODBC/OLEDB) the Database connection settings TopView SQL can access both local and remote databases. The location of the database is specified as part of the Database Alias connection settings. Database List screen The Database List screen displays the Database Aliases that have been defined. To create a new Database Alias, click [New DB Alias ]. To edit and existing Database Alias, select the Database Alias from the list and click [Edit DB Alias ]. To create/edit the Queries associated with a Database Alias, select the Database Alias from the list and click [Edit Queries ]. 10

To test the connection to a Database Alias, select the Database Alias from the list and click [Test connection]. Database Alias Edit screen The Database Alias Edit screen is displayed when the user creates a new Database Alias or edits an existing Database Alias. If the user is creating a new Database Alias, a unique name for the Database Alias should be entered. Connection type Each Database Alias can be accessed via ODBC or OLEDB. Select the type of connection for the Database Alias. For more information on connection type, see Database Communication Requirements on page 4. 11

ODBC Connection Details ODBC connections require an ODBC driver to the vendor database. If an ODBC driver is not installed for your database, please contact your database vendor. ODBC Databases require that the user enter the Datasource Name (DSN) for the ODBC connection. A DSN is defined outside of TopView SQL through Control Panel Data Sources (ODBC). This utility can also be launched by clicking the [ODBC Data Source Administrator ] button. Note: If a new DSN is created while the Database Alias Edit screen is open, the user may need to click the refresh button to update the list of DSN s in the DSN dropdown. DSN type (use System DSN s!) Each DSN can be defined as User or System. User DSN s are visible to the currently logged in Windows User. System DSN s are visible to all users. Due to TopView s ability to run as a Windows Service using different user accounts, only System DSN s should be used by TopView SQL. DSN Select the name of the DSN for this Database Alias. Use the [Test connection] button to verify connection the selected database DSN. Click [OK] to save the Database Alias and return to the Database Alias List screen. 12

Additional connection parameters Used to specify additional connection parameters for the DSN. Example: the DSN may prompt for username/password upon connection. For TopView SQL, you would like to provide the username and password to prevent the prompt. The format of the additional parameter string is typically name1=value1; name2=value2; If this field is not blank, the ODBC connection string used by TopView for this database alias will be the concatenation of 1. The connection string generated by the DSN 2. A semicolon ; 3. The entered additional connection parameters 13

OLEDB Connection Details OLEDB connections require an OLEDB Provider (driver) to the vendor database. If no OLEDB Provider is installed for your database, please contact your database vendor. Unlike ODBC connections, most OLEDB connections will be completely defined within TopView SQL. Although there are multiple pieces of information displayed for OLEDB connections in the example screen above, the key setting is the Final connection string displayed at the bottom of the screen. The Final connection string contains the entire set of OLEDB connection settings used by TopView SQL for connection to the OLEDB database. All other settings on this screen are used to create the Final connection string. OLEDB connections require an OLEDB Provider (the name of the OLEDB Provider that is installed on the local computer for connection to the desired database) and a Data Source (usually the database location/name or database file name). Additional information in the Final connection string may include: security and/or login information a database name within the Data Source The contents and syntax of the Final connection string are specific to the OLEDB Provider. Although TopView SQL provides wizards to assist in the creation of the Final connection string, the user may need to research specific connection string syntax on the Internet or through vendor-provided documentation. 14

UDL Files: UDL files may already exist within your company for the desired OLEDB connection. UDL files are similar to ODBC DSN s in that they contain the complete list of OLEDB connection settings required to connect to an OLEDB database. If the user has a UDL file for the OLEDB database and would like to use the UDL file instead of specifying a connection string, the Final connection string should be set to: File Name=c:\pathtofile\filename.udl No other OLEDB settings are required. OLEDB Provider Select the OLEDB Provider that should be used to connect to the database. The selected Provider, X, sets the Provider=X portion of the connection string. Data Source The data source usually refers to the database that the provider will connect to. The syntax of the data source will change based on the selected provider name. The entered Data Source, Y, sets the Data Source=Y portion of the connection string. Base connection string The Base connection string is the connection string created from the selected OLEDB Provider and Data Source. To copy this connection string to the Final connection string, click the [Copy to Final] button. 15

OLEDB Connection String Builder (wizard) The OLEDB Connection String Builder launches a wizard that can be used to construct the connection string. After the wizard is closed, the connection string is returned to the Wizard Connection String text box. In the Wizard: Verify that the correct Provider is selected: 16

Set the desired data source and logon information for the database: Set any Advanced settings and modify any settings on the All tab: Click OK to return the connection string to the Wizard Connection String text box: Wizard Connection String The Wizard Connection String is the result of the Connection Wizard utility. To copy this connection string to the Final connection string, click the [Copy to Final] button Investigate connection strings online Click to launch a web browser and view the information at connectionstrings.com. When researching connection strings, match the OLEDB Provider (e.g. SQLNCLI.1 in the above example) to the information listed on this site for your database. 17

Final connection string The Final connection string contains the complete set of connection information required for connection to the OLEDB database. This is the connection information that will be stored to the Database Alias and used for connecting to the database. To test the Final connection string, click the [Test connection] button. 18

Configuring Queries Once one or more Database Aliases have been created, the user can create Queries against the Database Alias. The TopView SQL Tags will be configured from the Query results. To create or edit Queries for an existing Database Alias, select a Database Alias from the Database Alias List screen and click the [Edit Queries] button. 19

Query List screen The Query List screen displays the existing Queries for a Database Alias. To create a new Query, click the [New Query ] button. To edit an existing Query, select the Query in the list and click the [Edit Query ] button. Export/Import Queries The list of Queries for the current Database Alias can be exported to a comma delimited file (CSV) for bulk configuration using an external tool (e.g. Microsoft Excel). The exported file can be edited, allowing the user to create, delete or edit multiple Queries. Once the edits have been saved, the user can import the changes back into the TopView SQL Configuration. If the user has already configured one or more Queries, they should easily see this information in the exported file. Notes for exported values: Each field value in the exported file in enclosed in square brackets. Since a comma in the CSV file will be interpreted as a new field, any field values that contain commas are converted to a ~ in the CSV file. Double quotes ( ) are converted to ^^ in the exported file, and changed back to double quotes during an import. 20

Query Edit screen The Query Edit screen is displayed when the user creates a new Query or edits an existing Query. If the user is creating a new Query, a unique Query name within the Database Alias should be entered. 21

Select Query The Select Query is the SQL SELECT statement for the query, or a stored procedure (with arguments) that executes a query within the database. The structure of the SELECT statement is based on SQL (Structured Query Language). Although there may be specific syntax, functions, or keywords within the SELECT statement that are vendor specific, most databases support the same basic SELECT structure. SELECT columns FROM table WHERE condition The most common vendor-specific differences involve date and/or time expressions within the SELECT statement. This documentation does not provide an in-depth tutorial on the SELECT statement syntax and structure. If you need assistance, please consult your database documentation or online resources. Referencing current time in SELECT Within the SELECT statement, there may be a need to compare a returned column date/time to current time or an offset from current time. Most databases contain functions such as Now() that can be included in a SELECT statement. These vendor-specific date functions and keywords are resolved by the database and are permitted in TopView SQL. Please see your database vendor documentation for more information. To support current time and offsets regardless of databases vendor, TopView SQL contains a current time placeholder that can be used within the SELECT statement. Example: SELECT * FROM mytable WHERE TIME_OF_READING > %time_current% Before the SELECT statement is passed to the database for execution, TopView SQL will replace %time_current% with the current time as yyyy-mm-dd hh:mm:ss If your database requires that a passed date be enclosed in specific characters (e.g. single quote, double quote, pound#), %time_current% should appear within these characters. Examples: SELECT * FROM mytable WHERE TIME_OF_READING > %time_current% SELECT * FROM mytable WHERE TIME_OF_READING > %time_current% SELECT * FROM mytable WHERE TIME_OF_READING > #%time_current%# Offsetting current time To offset the current time placeholder, enter the offset amount as +/-Nd h m s where +/- add or subtract from current time N a number of units d, h, m, s days, hours, minute, seconds Offset examples: %time_current-1h% 1 hour before current time %time_current-2d% 48 hours before current time 22

Query Placeholders Within the SELECT statement, TopView supports three placeholders named P1, P2, and P3. The purpose of these placeholders is to reduce the number of Queries that must be created when there are minor differences between the Queries. Example: Two Queries without placeholders: SELECT * FROM tankdata WHERE TANK_ID LIKE T0001 SELECT * FROM tankdata WHERE TANK_ID LIKE T0002 One Query with placeholder: SELECT * FROM tankdata WHERE TANK_ID LIKE %P1% If a Tag s assigned Query has placeholders, the Tag definition must provide values for each placeholder. Placeholder notes: Each placeholder P1, P2, P3 must be surround by the percent symbol within the SELECT statement: %P1%, %P2%, %P3% The Query contains placeholders checkbox must be checked if the SELECT statement contains placeholders. Naming returned columns By default, the name of the returned columns from a SELECT Query match the names of the table columns. Most databases support a SELECT statement syntax using AS that names the returned columns. Since each Tag definition may need to name various columns in the Query results, you may want to change the columns names within the Query results. Example#1: Default column names SELECT TANK_ID, Temperature FROM tankdata WHERE tank_id='t4500' Example#2: Named temperature column name SELECT TANK_ID, Temperature as TankTemp FROM tankdata WHERE tank_id='t4500' 23

Calling Stored Procedures Stored Procedures are named, predefined functions within a database that execute logic. Procedures are used to standardize operations performed against the database, including queries through SELECT statements. Instead of entering a SELECT statement for the Query in TopView SQL, the user may instead want to execute an existing procedure that performs a SELECT query and returns the results. To call a procedure, the procedure name and arguments can be entered instead of a SELECT statement: Note: argument names many not be required when calling a procedire: GetTankLevel @tankid= T0001 or GetTankLevel T0001 Run Query Press the [Run Query] button to test and execute the entered Select Query (SELECT statement or stored procedure). If the Select Query contains placeholders (based on the Query contains placeholders checkbox), the user will be prompted for the placeholder values before the Query is executed: 24

Test results Displays the results of a successful test query execution. The user can see the returned records (rows) and column names in the results list. Min. Interval Defines the minimum interval at which this Query will execute when called by the real-time TopView Alarm and Notification Engine. This setting can be used to reduce the query execution interval. Each TopView configuration contains a refresh interval. This user-entered refresh is the interval at which the monitored Tag values are retrieved. During a TopView SQL refresh, each unique Query is executed once if the Query has not been executed within the Minimum interval. Depending on the specific data within the Query, or based on query loading on the underlying database, the user may want to reduce the Query execution frequency through the Min Interval. Description/Comments User-entered Query description and comment are stored with the Query. Query description is displayed on the Query List screen. Query comments can be used to explain the details of the query settings and entered SELECT statement. 25

Configuring Tags After the user has created Database Aliases and Queries, TopView SQL Tags can be created. Tags are specific results returned from a Database Query. A single Query can feed data to multiple Tags, therefore reducing the overhead of Query execution. Each Tag has an assigned Database Alias, Query, and lookup filter. The lookup filter instructs TopView of the location of the Tag value, and optionally Tag timestamp, within the Query results. Tag List screen The Tag List screen displays existing TopView SQL Tags. This Tag list includes Tags for all Databases. To create a new Tag, click the [New Tag ] button. To edit an existing Tag, select the Tag in the list and click the [Edit Tag ] button. To rename an existing Tag, select the Tag in the list and click the [Rename Tag ] button. 26

Export/Import Tags The list of all Tags can be exported to a comma delimited file (CSV) for bulk configuration using an external tool (e.g. Microsoft Excel). The exported file can be edited, allowing the user to create, delete or edit multiple Tags. Once the edits have been saved, the user can import the changes into the TopView SQL Configuration. If the user has already configured one or more Tags, they should easily see this information in the exported file along with the entered values. Notes for exported values: Each field value in the exported file in enclosed in square brackets. Since a comma in the CSV file will be interpreted as a new field, any field values that contain commas are converted to a ~ in the CSV file. Double quotes ( ) are converted to ^^ in the exported file, and changed back to double quotes during an import. 27

Tag Edit Screen The Tag Edit screen is displayed when the user creates a new Tag or edits an existing Tag. Description/Units User entered Tag description and measurement units. Database and Query Select the Database and Query whose results contain the Tag value and optional Tag timestamp. If the selected Query contains placeholders, enter the value of each placeholder for the current Tag in the P1, P2, and P3 placeholder text box. Run Query Press the [Run Query] button to execute the selected Query using the placeholders defined for the current Tag. 28

Query lookup filter The lookup filter instructs TopView SQL of the location of the tag value, an optionally the tag timestamp, within the Query result records. This lookup involves two items: 1. The record containing the Tag value and optional timestamp 2. The column name within the Query record containing the Tag value; the column name within the Query record containing the optional Tag timestamp. Note: if you are editing the lookup filter, you should first execute the query using the [Run Query] button. This will fill the column dropdowns with the available columns from the Query results. Get first record, Where If the Tag value always exists in the first record of the returned query, or if the Query always returns one record, the Where clause is not required and the user can uncheck the Where checkbox. Note: the order of the records returned in a Query can be controlled by using the ORDER BY SQL keyword. Example: return all records from table tankdata ordered by column time descending SELECT * FROM tankdata ORDER BY time DESC Where The Where filter of the lookup filter allows the user to locate a specific record in the Query results by matching the value of a column in the returned Query recordset to a specific value. In the above example, TopView SQL will locate the first record in the query results where the column TANK_ID column has a value of T0003. Tag value column For the matching record in the Query results, the Tag value column is the name of the column in the matching record that contains the tag value. The data type of this column may be numeric, date, or string. Tag timestamp column By default, the timestamp for the Tag value is the time that the query is executed by TopView. If the Value record contains a date column that should be used as the Value timestamp, select the column name. Otherwise, leave the timestamp column blank. 29

Tag Value, Status, Timestamp Notes When the TopView Alarm and Notification Engine executed a Query and returns the current tag information, there are 3 pieces of information that are returned for the Tag: Value The Tag value is the column value from a specific record returned from the Query as defined in the Tag s lookup filter. The data type of the value may be numeric, date, or string. Timestamp of the Value The timestamp of the value is, by default, the time at which the Query was performed. Optionally, the Tag can define a column from the Value record of the returned Query that contains the timestamp. If the timestamp cannot be retrieved, it is set to the Query time. Status of the Value If TopView is able to retrieve the Value, the status is set to Good. If TopView is unable to retrieve the value (not connected to Database, Query failed, or Tag value record/column cannot be located in Query results), the status is set to bad. 30

Tag Search Once you have defined Tags in TopView SQL, you can easily add Tags to the TopView Monitored Tag list. 1. Start the TopView Configurator 2. If you are editing an existing configuration, open the configuration file 3. On the Tags and Limits screen of the Configurator, click the [Tag Search] button 4. The Tag Search dialog will appear 31

5. Use the Filter by Database dropdown to select the desired Database or choose All Databases to show the Tags for all Databases. 6. To see the more properties for the selected Tag, click the [Tag properties ] button. 7. To return one or more Tags to the TopView Monitored Tag List: Select one or more Tags in the list and click [Return selected Tags]. To select multiple tags, hold down the CTRL key and click each tag. To select a range of Tags, select the first tag in the range, hold down the SHIFT key, then select the last Tag in the range. 32

TopView SQL Examples Access Database TopView SQL installs a sample Microsoft Access Database. The Database is contained in the file tankdata.mdb located in the TopView DataPath\SQL\ folder. To open the TopView DataPath folder, select Tools Open DataPath Folder from the top menu of the TopView Configurator. Sample Access table Within the sample database is a single table named TankData Sample Access table columns TANK_ID Text: the tank ID T0001 through T9000 Level Numeric: a level reading for the tank Temperature Numeric: a temperature reading for the tank Description Test: a description of the tank Time Date/Time: the time of level and temperature readings 33

Defining a Database Alias for the sample Access database Run the TopView SQL Configurator. For more information, see Launching TopView SQL Configuration on page 8. Click Create/Edit Databases and Queries Click [New DB Alias ] Enter the Database Alias name SAMPLE You can access the sample database using ODBC or OLEDB. Set the connection type to ODBC or OLEDB and follow the instructions below for each connection type. ODBC Select connection type ODBC Define a System DSN for the sample database. Click [ODBC Data Source Administrator] to create a new DSN Select the System DSN tab and click [Add ] For driver, select Microsoft Access (*.mdb) Enter the Data Source Name: SampleAccessDB Press [Select ] to select the file DataPath\SQL\tankdata.mdb Click [OK], [OK] and return to the Database Alias Edit screen On the Database Alias Edit screen For DSN type, select System DSN For DSN, select SampleAccessDB 34

OLEDB Select connection type OLEDB Set the OLEDB Provider to Microsoft Jet 4.0 OLEDB Provider Click OLEDB Connection String Builder (wizard) On the Connection tab, select or enter a database name, click [ ] to browse to the file DataPath\SQL\tankdata.mdb Clear the User name text box Click [OK] to close the wizard dialog. The full OLEDB connection string should now appear in the Wizard Connection String text box. Click [Copy to Final], next to the Wizard Connection String text box, to copy the connection string to the Final connection string textbox 35

Click [Test connection] to verify that the connection succeeds 36

Defining a Query for the sample Access database From the Database Alias List screen, select the Alias named SAMPLE and click [Edit Queries ] Click [New Query ] to create a new Query against the SAMPLE Database. Enter the query name: GetAllRecords Enter the Select Query: SELECT * FROM tankdata Click [Run Query] to test the Query execution Click [OK] to save the Query 37

Defining a Tag for the sample Access database Run the TopView SQL Configurator. For more information, see Launching TopView SQL Configuration on page 8. Click Create/Edit Tags Click [New Tag ] Enter the name SampleLevel5000 This tag will read the level value for tank T5000 On the Tag Edit screen Select the Database SAMPLE Select the Query GetAllRecords Click [Run Query] to execute the GetAllRecords Query In the Query lookup filter o o Set the Tag value column to Level Check Where checkbox and set the comparison to TANK_ID = T5000 Click [Test filter] and verify that the level of tank T5000 is highlighted in the Query Results and that the displayed filtered result is correct Click [OK] to save the Tag From the TopView Configurator, you can now add the Tag SampleLevel5000 to the list of monitored points. Use the [Tag Search] button from the Tags and Limits screen to select the tag and add it to the list of monitored tags. 38

Text file Database Using the Microsoft Text File ODBC Driver, TopView SQL can monitor values from one or more text files. TopView SQL installs a sample text file that can be queried. The text file TankData.txt is located in the TopView DataPath\SQL\ folder. To open the TopView DataPath folder, select Tools Open DataPath Folder from the top menu of the TopView Configurator. Copy the sample text file to c:\textfiles\ The location of the sample text file may not be browsable from the Microsoft Text File ODBC Driver dialog. Based on the location of the TopView DataPath, the root folder may be hidden. Therefore, for this tutorial we will copy the sample text file to c:\textfiles\ and will reference the file c:\textfiles\tankdata.txt Sample Text file The sample text file contains level and temperature readers per tank. There are 9000 tanks in the file. 39

Sample table columns TANK_ID Text: the tank ID T0001 through T9000 Level Numeric: a level reading for the tank Temperature Numeric: a temperature reading for the tank Description Test: a description of the tank Time Date/Time: the time of level and temperature readings 40

Defining a Database Alias for the sample text file Run the TopView SQL Configurator. For more information, see Launching TopView SQL Configuration on page 8. Click Create/Edit Databases and Queries Click [New DB Alias ] Enter the Database Alias name SAMPLETEXT You can access the sample text file using the Microsoft Text File ODBC Driver. ODBC Select connection type ODBC Define a System DSN for the sample database. Click [ODBC Data Source Administrator] to create a new DSN Select the System DSN tab and click [Add ] For driver, select Microsoft Text Driver (*.txt, *.csv) 41

On the ODBC Text Setup dialog, Click the [Options] button o Enter the Data Source Name: SampleTextDB o Uncheck Use Current Directory o Click [Select Directory] and select c:\textfiles o Click [Define Format] 42

o o o Under Tables, select tankdata.txt Check the Column Name Header checkbox Click the [Guess] button The columns should be displayed. The assumed data type displayed for each column should be correct. You can override any of the column settings but for this example we will use the defaults (from the Guess) o o o Click [OK]. If you see the message Failed to save table attributes of (null) into (null), you can ignore the error. This is a known problem with the Microsoft Driver and the recommended action is to ignore it. Click [OK] to close the ODBC Text Setup dialog Click [OK] to close the ADBC Data Source Administrator 43

On the Database Alias Edit screen For DSN type, select System DSN For DSN, select SampleTextDB Click [Test connect] to test the connection 44

Defining a Query for the sample text file From the Database Alias List screen, select the Alias named SAMPLETEXT and click [Edit Queries ] Click [New Query ] to create a new Query against the SAMPLE Database. Enter the query name: GetAllRecords With the text file ODBC Driver, each file is considered a table Enter the Select Query: SELECT * from tankdata.txt Click [Run Query] to test the Query execution Click [OK] to save the Query 45

Defining a Tag for the sample text file Run the TopView SQL Configurator. For more information, see Launching TopView SQL Configuration on page 8. Click Create/Edit Tags Click [New Tag ] Enter the name SampleTemperature5000 This tag will read the temperature value for tank T5000 On the Tag Edit screen Select the Database SAMPLETEXT Select the Query GetAllRecords Click [Run Query] to execute the GetAllRecords Query In the Query lookup filter o o Set the Tag value column to Temperature Check Where checkbox and set the comparison to TANK_ID = T5000 Click [Test filter] and verify that the temperature of tank T5000 is highlighted in the Query Results and that the displayed filtered result is correct Click [OK] to save the Tag From the TopView Configurator, you can now add the Tag SampleTemperature5000 to the list of monitored points. Use the [Tag Search] button from the Tags and Limits screen to select the tag and add it to the list of monitored tags. 46