1 Odbc: 1.1 Window Composition
1 Odbc: 1.1 Window Composition
1 ODBC
ODBC (Open DataBase Connectivity) is a standard of access method to the database. By
connecting CIMON-SCADA to the common databases such as Access, Oracle, the user
may register data to the common databases or acquire the data from the database
system. Also, using a standard SQL query enables the user to manage the database by
updating, registering, removing the data.
1
On the left side of the window, the DSN of the database system, which is connected to
CIMON-SCADA, and its queries are displayed in tree form. On the right side of the
window, the queries of the selected DSN are listed.
1
DSN(Data Source Name): Name of the application which requested a connection to the data source.
1-1
ODBC
1.2 Menu
You can configure the DSN of the new DBMS, which will be connected to CIMON-
SCADA system. You can bring up the [DBMS Configuration] system by selecting [Edit] –
[New DBMS] or icon.
Item Description
Enter the ODBC DSN. The name must be identical to the name of the DSN
DB Name registered at “Control Panel\System and Security\Administrative
Tools\ODBC Data Sources”.
Enter the User ID to connect the database assigned to the ‘DB Name’. The
User ID User ID must have authority to process the queries. If you do not need the
User ID, you may leave the field blank.
If you assigned a User ID, enter the password for the ID. If you have not
Password assigned a User ID or it is not necessary to use password, leave the field
blank.
Description Enter the description of the currently configuring database.
1-2
│CIMON-SCADA Help User’s Manual│
After the registration of new DBMS, press icon to bring up the [Query
Configuration] window. You can configure the queries of the DBMS in this window.
Item Description
1-3
ODBC
[SELECT Statement]
You can configure the SELECT Statement when you have selected the ‘SELECT
Statement’ in the [Query Configuration] window. You may configure the SELECT
Statement in 4 sections.
When you link a tag, the data type in DBMS and CIMON-SCADA must be
identical. Also, be aware of the data capacity when you use string field.
E.g.) If data type in DBMS is ‘SMALLINT’, ‘SMALLINT’ must be selected in
ODBC.
1-4
│CIMON-SCADA Help User’s Manual│
Item Description
No Duplicate Data Select the checkbox to avoid the duplicated data in the Query results.
Defines the record field created by the execution of query. You can bind the
record field and the CIMON-SCADA tag.
Field Name Enter the field name which is defined in the database table.
Assign the tag to be bound to the field. The value of the tag
may be written to the database or the value from the
Tag Name
database can be written to the tag. Generally, the virtual
tags are assigned.
Displays the list of tags in the CIMON-SCADA. You may
Browse
select a tag to assign the value to the ‘Tag Name’ field.
Selects the data type of the assigned field. The selected data
New Field type must be identical to the data type assigned in the
DBMS.
Data Type
DBMS CIMON-SCADA
Edit You may select the configured field on the list and edit the field.
1-5
ODBC
[Others]
You can configure the other statement when you have selected the ‘Others’ in the
[Query Configuration] window.
When you link a tag, the data type in DBMS and CIMON-SCADA
must be identical. Also, be aware of the data capacity when you
use string field.
When you write an SQL statement, you must use quotation marks
to the tag value which corresponds to the string field in the DBMS.
E.g.) When there are numeric tags [1], [2] and string tag [3] in the
1-6
│CIMON-SCADA Help User’s Manual│
Item Description
Assign the tag which will correspond to the SQL statements. When you edit
Binding the SQL statement, assign the value area as “[n]”(n: Decimal Integer). This
area will be replaced with the corresponding tag value.
Assign a tag to be bound to the SQL statement.
Enter the tag name. The assigned tag value will replace the
Tag Name
[n] area of the SQL statement.
Displays the list of tags in the CIMON-SCADA. You may
Browse
select a tag to assign the value to the ‘Tag Name’ field.
Selects the data type of the assigned field. The selected data
type must be identical to the data type assigned in the
Data Type
DBMS CIMON-SCADA
1-7
ODBC
Edit You may select the configured field on the list and edit the field.
Delete Deletes the selected field.
▲/▼ Moves the selected field upward or downward.
Write a standard SQL. You may assign the value area as [n]. [n] will be
SQL
replaced with the tag value of corresponding number.
(4) Edit
Press icon to edit the selected DBMS or queries in the corresponding configuration
window.
(5) Delete
1-8
│CIMON-SCADA Help User’s Manual│
Command Description
Let the database manager execute the query and receive the
Subroutine CSqlOpen
result.
Subroutine CsqlClose Closes the query in the database and ends the operation.
2
Subroutine operates a certain action without any value returned, unlike the functions have return value.
1-9
ODBC
1-10
│CIMON-SCADA Help User’s Manual│
CSqlOpen Let the database manager execute the query and receive the result.
CSqlClose Closes the query in the database and ends the operation.
Command CSqlClose (“Query Name”)
Subroutine
Script CSqlClose “Query Name”
Ends the query when the operations with CSqlOpen and curser-related
1-11
ODBC
CSqlDelete Deletes the currently displayed record from the database manager.
Command CSqlDelete (“Query Name”)
Subroutine
Script CSqlDelete “Query Name”
Deletes the selected record from the DBMS. ‘Query Name’ must be registered
Description as SELECT statement in ODBC configuration window. Also, CSqlOpen
function must be executed beforehand.
Deletes the currently displayed record from the query named ‘RetrieveAll’.
Example
CSqlDelete(“RetrieveAll”)
Moves the current cursor to the topmost record. The indicated record data
replaces the corresponding tag value.
Description
‘Query Name’ must be registered as SELECT statement in ODBC configuration
window. Also, CSqlOpen function must be executed beforehand.
Retrieves the topmost record data of query named ‘RetrieveAll’ to the
CSqlFirst(“RetrieveAll”)
Reads the data of the assigned Record Number from ‘Query Name’ to the
connected tag.
Description
The ‘Record Number’ starts at 1. If you assign the ‘Record Number’ as –n, it
Reads the first record data of the query named ‘RetrieveAll’ to the bound tag.
Example
CSqlGetRecord(“RetrieveAll”, 1)
1-12
│CIMON-SCADA Help User’s Manual│
Assigns the tag values as field value on the moment of the subroutine
execution. Then composes a new record and adds to the DBMS.
Description
‘Query Name’ must be registered as SELECT statement in ODBC configuration
window. Also, CSqlOpen function must be executed beforehand.
Inserts a new record to the query named ‘RetrieveAll’.
Example
CSqlInsert (“RetrieveAll”)
Moves the current cursor to the last record and the indicated field value is
moved to the connected tag.
Description
‘Query Name’ must be registered as SELECT statement in ODBC configuration
window. Also, CSqlOpen function must be executed beforehand.
Reads the last record data from the database and saves it to the connected
Example tag.
CSqlLast (“RetrieveAll”)
1-13
ODBC
Moves the current cursor to the next record and the indicated field value is
moved to the connected tag.
Description
‘Query Name’ must be registered as SELECT statement in ODBC configuration
window. Also, CSqlOpen function must be executed beforehand.
Reads the next record data from the database and saves it to the connected
Example tag.
CSqlNext (“RetrieveAll”)
Moves the current cursor to the previous record and the indicated field value is
moved to the connected tag.
Description
‘Query Name’ must be registered as SELECT statement in ODBC configuration
window. Also, CSqlOpen function must be executed beforehand.
Reads the previous record data from the database and saves it to the
CSqlPrev (“RetrieveAll”)
1-14
│CIMON-SCADA Help User’s Manual│
Reconnects to the DBMS. To use DBMS when the connection is broken due
to the unexpected reason, you must use this subroutine.
Description
The DBMS named ‘DBMS Name’ must be registered in CIMON ODBC
configuration.
Reconnects to the DBMS named ‘SampleDB’.
Example
CSqlReconnect (“SampleDB”)
CSqlRequery Executes the query again and reads the record data again.
Command CSqlRequery (“Query Name”)
Subroutine
Script CSqlRequery “Query Name”
Executes the assigned query’s SELECT statement, and reads the record data
again.
Description
‘Query Name’ must be registered as SELECT statement in ODBC configuration
window. Also, CSqlOpen function must be executed beforehand.
Executes the query named ‘RetrieveAll’ again and reads the record data again.
Example
CSqlRequery (“RetrieveAll”)
1-15
ODBC
CSqlUpdate Updates the record data from database manager with the current tag value.
Command CSqlUpdate (“Query Name”)
Subroutine
Script CSqlUpdate “Query Name”
Updates the record data from database manager with the tag value indicated
by the cursor.
Description
‘Query Name’ must be registered as SELECT statement in ODBC configuration
window. Also, CSqlOpen function must be executed beforehand.
Updates the record data from database manager with the tag value indicated
CSqlUpdate (“RetrieveAll”)
Executes the command in SQL statement to database. You may use double
Description
quotation marks (“ “) to use the SQL as the second parameter.
Execute the SQL in ‘SampleDB’ , which changes the ‘Data1’ field value of the
Number = 4")
1-16
│CIMON-SCADA Help User’s Manual│
CSqlGetError You can find the error with the return value of the function.
Operation CsqlGetError(“Query Name”)
Function
Script n = CsqlGetError “Query Name”
This function checks out the operation state of the latest ODBC functions such
Description as SCqlInsert and CSqlOpen. If the function operated properly, this function
returns 0. Other return values indicate the errors.
Checks the operation state of the latest function which is executed on the
Example query named ‘RetrieveAll’.
X = CSqlGetError(“RetrieveAll”)
Cannot close the record due to other references. The function is executed while the
103
database is opened.
The name of the data source does not exist and the base driver is not assigned. Data
1001
source name and the base driver are not assigned in Windows.
Failed to read data since the data does not exist beyond the cursor on the data
1002
source.
Failed to find the assigned field from the record. Or, the query requested by the
1003
SELECT or Other statements are invalid.
1004 The data type of the record and tag data are not equal.
1-17
ODBC
Failed to update or delete the record. CsqlUpdate or CsqlDelete function is used for
1005 the data which have been already changed. The error occurs when the function is
executed again when the changes are not updated.
Duplicated values are entered in the index, basic key or relation, but the requested
1006 changes are not applied. The error occurs when the data is duplicated in the same
field.
1008 Tried data loading after the deletion of the record data.
This section explains the basics of the feature. Please utilize the feature
according to your site environment.
In the CIMON-SCADA above version 2.4, the version has been changed to the Dynaset.
Therefore, the user cannot use the MS SQL Server driver to connect SCADA and ODBC.
In this case, use CIMON-SCADA V2.3 or lower versions. Alternatively, you may create a
script like “SQL_Select” as shown below.
Sub SQL_Select()
conn.Open ConnStr
‘//Inquiry
rs.close
1-18
│CIMON-SCADA Help User’s Manual│
conn.close
set rs = nothing
End Sub
Sub SQL_INSERT()
conn.Open ConnStr
‘//Insert
'rs.close
conn.close
Set rs = nothing
End Sub
1-19
ODBC
1.4 Exercise
This section explains the basics of the feature. Please utilize the feature
according to your site environment.
In this example, the database created in Microsoft Access will be added to DSN and
modified through the CIMON-SCADA.
a) Open Microsoft Access and create a new database named Sample.mdb. Assign the
path and press [Create] button.
b) Designate the table name as DataTable. Right-click on the [Table1] and press
[Design View] to configure the table.
1-20
│CIMON-SCADA Help User’s Manual│
d) Save the configuration and double-click the table name on the left side of the
window. Then the screen will be changed as shown below to add records.
1 3.14 Process
2 19.5 Assembly
3 0.02 Examination
4 128.3 Shipment
1-21
ODBC
To use the configured database in CIMON-SCADA, you must register the database as
DSN.
If you are using a Windows Vista or above, and 64-bit OS, you must execute
‘odbcad32.exe’ in C:\Windows\SysWOW64 as administrator.
1-22
│CIMON-SCADA Help User’s Manual│
On Windows bootup, the user may log on with different user IDs. [User
DSN] is a DSN which allows only the specified user ID to use. [System DSN]
is a DSN which allows all users of the system to use.
c) In the [Create New Data Source] window, select the corresponding driver and press
[Finish]. If you are using Microsoft Access, select Microsoft Access Driver(*.mdb).
d) In the [ODBC Microsoft Access Setup] window, enter the Data Source name and
select [Select] button in ‘Database’ field. The Data Source name must be identical to
the name assigned in CIMON-SCADA ODBC.
1-23
ODBC
e) In the [Select Database] window, find the database file named ‘Sample’ and press
[OK] to finish the configuration. If the file path changes, you must configure the
current settings again.
f) If the DSN is added correctly, the path of the file will be displayed on the [ODBC
Microsoft Access Setup] window. Press [OK] to finish the ODBC configuration.
1-24
│CIMON-SCADA Help User’s Manual│
a) Select [Tools] – [ODBC] or icon. Alternatively, you may double-click the [ODBC]
on the Project Workspace.
1-25
ODBC
In CIMON-SCADA, the user may use standard SQL to write a query about the external
common database. In other words, you may acquire a data from the database and save
it in the tag, using SELECT statements.
a) In [ODBC] window, select [Edit] – [New Query] or icon to create a new query
about the DBMS.
1-26
│CIMON-SCADA Help User’s Manual│
b) Press [Create SQL] button to bring up the [QUERY : SELECT Statement] window
and configure the details of the query. Press [New Field] to connect the database
table field and the CIMON-SCADA tag.
1-27
ODBC
c) After configuring the connection between field and the tag, enter the table name
at ‘FROM’ field and press [OK] to end the configuration. In this example, enter
DataTable in the ‘FROM’ field and leave ‘WHERE’ and ‘ORDER BY’ fields blank.
1-28
│CIMON-SCADA Help User’s Manual│
After saving the ODBC configuration, compose the graphic page to check the database
value as shown below.
Functionality Touch
Action Command Expression
Command CSqlOpen("RetrieveAll")
Let the database manager execute the query (RetrieveAll) and receive the
Description
result
b) Create objects to display the tag value which are storing the field data.
1-29
ODBC
Functionality Touch
Action Command Expression
Command CSqlFirst("RetrieveAll")
Functionality Touch
Action Command Expression
Command CSqlPrev("RetrieveAll")
Functionality Touch
Action Command Expression
Command CSqlNext("RetrieveAll")
Functionality Touch
Action Command Expression
Command CSqlLast("RetrieveAll")
d) Save the configured page and execute the project with CimonX.
e) Press the connection object. If the first record value appears on the page, you have
configured the connection successfully.
1-30
│CIMON-SCADA Help User’s Manual│
f) Use the touch objects shown below to check if the all records are displayed
properly.
Functionality EntryData
Action Numeric
Functionality EntryData
Action Numeric
Functionality EntryData
Action Text
Functionality Touch
Command CSqlInsert("RetrieveAll”)
c) Execute the project with CimonX and press the connection object.
1-31
ODBC
d) Create a new record using the ‘EntryData’ objects and press [Insert] button to add
the record to the database. Please do not duplicate the value assigned to ‘NUMBER’
tag and the ‘Number’ field.
e) Terminate the CimonX and open the database file to check if the new record is
added.
1-32
│CIMON-SCADA Help User’s Manual│
a) In [ODBC] window, select [Edit] – [New Query] or icon to create a new query
about the DBMS.
1-33
ODBC
1-34
│CIMON-SCADA Help User’s Manual│
Functionality Touch
Command CSqlRequery("RetrieveAll”)
e) Create objects to check and change the values of the newly added tags.
(ODBC.NONSEL.NUMBER, ODBC.NONSEL.DATA1, ODBC.NONSEL.DATA2)
Functionality Touch
Action Command
Command CSqlRun("InsertRecord")
1-35
ODBC
g) Execute the project with CimonX and change the values of tags
(ODBC.NONSEL.NUMBER, ODBC.NONSEL.DATA1, ODBC.NONSEL.DATA2) as
shown below. Then press [Insert record with SQL statement] button to execute the
assigned command expression.
h) To check the added data, press the connection object. When the first record
appears on the window, press button to execute CSqlLast("RetrieveAll")
function.
1-36
│CIMON-SCADA Help User’s Manual│
i) Terminate CimonX and open the database file to check the updated data.
Functionality Touch
Command CSqlDelete("RetrieveAll")
b) Execute the project with CimonX and press the connection object.
c) When the first record data appears on the screen, use buttons to
display the record to be deleted.
1-37
ODBC
f) Terminate the CimonX and open database file to check if the deleted record still
exists.
a) In [ODBC] window, select [Edit] – [New Query] or icon to create a new query
about the DBMS.
1-38
│CIMON-SCADA Help User’s Manual│
b) Press [Create SQL] button to bring up the [QUERY : Others] window. Press [New
Tag] button to connect the database table field and the CIMON-SCADA tag. In
[SQL] field, use standard SQL to write a query.
Use ODBC.NONSEL.NUMBER tag to indicate the record to be deleted.
Functionality Touch
Command CSqlRun("DeleteRecord")
1-39
ODBC
e) Execute the project with CimonX and assign the key value of the record to be
deleted to ODBC.NONSEL.NUMBER tag. Then press the [Delete record with SQL
statement] button to delete.
f) You can check the result by using ‘RetrieveAll’ query or opening the database file
after the termination of the CimonX.
Functionality Touch
Command CSqlUpdate("RetrieveAll")
1-40
│CIMON-SCADA Help User’s Manual│
b) Execute the project with CimonX and press the connection object.
c) When the first record data appears on the screen, use buttons to
display the record to be updated.
Functionality EntryData
Action Numeric
e) Change the value and press [Update] button to update the change.
f) Terminate the CimonX and open the database file to check the changed data.
1-41
ODBC
a) In [ODBC] window, select [Edit] – [New Query] or icon to create a new query
about the DBMS.
1-42
│CIMON-SCADA Help User’s Manual│
b) Press [Create SQL] button to bring up the [QUERY : Others] window. Press [New
Tag] button to connect the database table field and the CIMON-SCADA tag. In
[SQL] field, use standard SQL to write a query. At the place where the tag values
will replace, enter the unique number of the tag. Also, use quotation mark in the
string field.
1-43
ODBC
Functionality Touch
Action Command
Command CSqlRun("UpdateRecord")
f) To check the added data, press the connection object. When the first record
appears on the window, press button to find the changed
record.
1-44
│CIMON-SCADA Help User’s Manual│
g) You can also find the changes in the database file after the termination of CimonX.
1-45
ODBC
To use the configured database in CIMON-SCADA, you must register the database as
DSN.
If you are using a Windows Vista or above, and 64-bit OS, you must execute
‘odbcad32.exe’ in C:\Windows\SysWOW64 as administrator.
1-46
│CIMON-SCADA Help User’s Manual│
c) In [Create New Data Source] window, select the SQL Server and press [Finish].
d) In [Create a New Data Source to SQL Server] window, enter the name to represent
the data source and the SQL Server to connect. Enter the server as [IP, PORT] or
[SQL Host Name\Server name].
E.g.) 172.x.x.x, xxxx or SERVERNAME\SQLEXPRESS
1-47
ODBC
e) Change the SQL Server authenticity of the login ID and enter the Login ID, then
press [Next].
The ID must be registered beforehand. The ID ‘sa’ is a system administrator of SQL
Server and the password is assigned when you installed the SQL Server.
f) Change the default database and press [Next]. The database must be defined
beforehand.
1-48
│CIMON-SCADA Help User’s Manual│
h) [ODBC Microsoft SQL Server Setup] window will be brought up. Press [Test Data
Source] button to proceed the test, then press [OK[ to finish the ODBC
configuration.
1-49
ODBC
a) Select [Tools] – [ODBC] or icon. Alternatively, double-click the ODBC from the
Project Workspace.
b) To configure the DSN of the new DBMS in the [DBMS Configuration] window,
select [Edit] – [New DBMS] or icon.
1-50