You are on page 1of 5

Actions required to Configure SQL in iFIX

Part 1: Steps Required to Configure the ODBC Driver for your SQL
Database
1.

In Control Panel, double click on Administrative Tools then double click on Data
Sources(ODBC).

2. If you have not already setup a System DSN then click on the System DSN folder.
3. Choose the ADD button, and select the applicable ODBC Driver:
a) If you will be using an SQL relational database then select the SQL Server driver:

Enter a Data Source Name. This can be any name, and will be used later to connect
to the relational database from FIX/iFIX. Make a note of what is entered here.
Enter the Server Name then click the Next button.
Specify the information for how you want to verify the authenticity of the login;
select "With Windows NT Authentication using the Network Login ID" if you want
to use the existing logged on Windows operating system user to authenticate.
Click the Next button and complete the configuration information on the next two
screens and then click Complete.
Test the connection to the specified database.

b) If you will be using a Microsoft Access database (on the local machine only) then select
the Microsoft Access Driver (*.mdb):

Enter a Datasource Source Name. This can be any name, and will be used later to
connect to the relational database from FIX/iFIX. Make a note of what is entered
here.
Under the Database, click the Create button and specify an .mdb file name for and a
location to save the Access database file; this should be saved to C:\Dynamics\APP
directory (iFIX v. 3.5 and prior) or to C:\Program Files\GE Fanuc\Proficy iFIX\APP
directory (iFIX 4.0 and above).
Click OK twice once the Access .mdb database has been created.
The latest ODBC drivers for Microsoft can be located at:
http://www.microsoft.com/data/downloads.htm

c) If you will be using an Oracle relational database then select the Microsoft ODBC for
Oracle driver:

You

will need to have the required Oracle client and networking components
installed on the machine in order to be able to configure this connection.

Actions required to Configure SQL in iFIX

Part 2: Configuring the iFIX SQL Task


1. In System Configuration Utility (SCU), click Configure then select SQL.
2. From SQL Accounts screen, press the 'ADD' button. This will bring you to the SQL Login
Information screen and allow you to configure which relational database you are connecting to.
Choose the Database Type, and enter the Database Identifier (which is the Data Source Name
used in the ODBC driver configuration). You can use the '?' support to select this from a list.
Doing this will prevent any typos which would prevent the iFIX SQL option from connecting to the
database. Do NOT fill in a User Name and Password, unless you have enabled security in SQL.
Entries in these fields when there is no security enabled in SQL will cause you to not be able to
connect to the relational database. Press 'OK'.
3. Press 'Configure SQL Task...' button. This brings you to the SQL Task Configuration screen.
Select the 'Enable' radio button in the top left corner.
4. In the Database ID field; enter the Data Source Name again (in this exercise, this is the same as
was entered in the SQL Login Information screen). This specifies which Database ID will be used
to retrieve SQL commands from the SQLLIB table, as well as log errors in the SQLERR table.
5. In SQL cmd table field, type the name of your SQL command table. GE Fanuc recommends
always using SQLLIB for this table name, to avoid confusion.
6. In the Error log table field, enter the name of the table, which has been configured to receive
SQL errors. Once again, GE Fanuc recommends leaving this as the default of SQLERR.
7. Make sure that the 'Error msg to screen' and 'Debug msg to screen' boxes are checked. These
fields need to be checked when doing any ODBC troubleshooting, since they cause messages to be
displayed in the iFIX SQL Task. After doing this, press 'OK'. The iFIX SQL Task has now been
configured. Exit the SCU, making sure to save the changes. Verifying that an ODBC connection can
be made with your configuration.

Now, start iFIX and launch Mission Control and open the SQL Task window. There should be
messages in this window, and the final one should be 'Logged on to <database identifier>'. If there
is a message saying 'Error logging onto <database identifier>, then go back through these steps and
verify that the ODBC driver and iFIX SQL Task are correctly configured.

Actions required to Configure SQL in iFIX

Part 3: Configuring SQL Database Blocks


1. Open the iFIX Database Manager application and Add an SQT block. This first screen allows you
to configure WHEN the SQT will trigger. For this exercise, leave the Date Filters at the default
values.
2. Configure the SQT to trigger based either on a time event or a block event. Do not configure
both. In this exercise use a Block Event, so you will have total control of when the SQT will trigger
by simply changing the value of another tag. If you use a Time Event, you will have to configure an
Event Period, and then will have to wait that long before the command will trigger again.
3. To configure a Block Event on which this SQT will trigger: Enter the name of the tag and field,
which will cause this SQT to trigger. It should be a tag.field whose value can be changed by you
later. It does not matter if it is an analog or digital block. For this example use an AO or DO with
the SIM driver, since these are easily written to.
4. Next (if using a Block Event), choose the Event Type. A Change of Value event will trigger
whenever the tag.field changes. A Low to High or High to Low event will trigger when the value
changes from a '0' value to a non-zero value, or vice-versa.
5. Configure SAC Parameters fields as you would for any other block.
6. Press SQL Tab This allows you to configure what the SQT block does once it triggers. Block can
call a Procedure or a SQL command. If you are using SQL Command proceed with Step 7. If you are
using a Procedure proceed to Steps 8 and 9.
7. In SQL Name field, enter the name of the command, which will execute when the SQT triggers.
This name MUST match an entry from the SQLNAME column of the SQLLIB table, which resides in
the relational database (in this case, the ACC2 database in Access). To make this straightforward,
we will execute an INSERT command from the ACC2 database. The SQL Name of the command will
be INS, and the actual command looks like this: INSERT INTO TBL1 (COL2) VALUES (?);
This will INSERT a value (denoted by the ? and specified by a tag.field in the SQD block) into the
column named COL2 in the table named TBL1.
NOTE: You must know and understand the SQL command associated with this SQL Name, so that
you can configure the SQL Data block correctly.
8. In Database ID field; enter the name of the database (Data Source Name), which this SQL
command will be executed on. The reason for having this field is so that you can store the SQLLIB
and SQLERR tables in one database, while executing the command for the SQT block in another
database. If the SQLLIB table exists in the same database as the table, which the command will
execute upon, then this may be left blank. Since our SQLLIB table is part of the same database as
our TBL1 table, we can leave this blank.

Actions required to Configure SQL in iFIX

Part 3: Configuring SQL Database Blocks (cont.)


9. In the Command type box, check the SQL Command radio button. If we were executing a Stored
Procedure, we would choose that button. A Stored Procedure is just a list of SQL commands that
will be executed within the relational database, sort of like a command script. We send the name of
the Stored Procedure to the database, and it executes all the commands within the Stored
Procedure.
10. In the Advance Tab box, you can choose how many or which rows and columns of data are
accepted from a SQL SELECT command. The Columns and Rows fields are used differently for
each of the methods of data retrieval (Single, Multiple, or Array). For more information on this,
consult pp.73, 77-80 of the "What's New for v5.5" manual. To get you started using the SELECT
command however, use the Single Row with a value of '1' in the Rows field. This will return the
first row of data from the relational database table, which meets the query condition(s). However,
since we are currently performing an INSERT command, we do not have to change these settings.
This information is for reference when performing further ODBC testing/experimentation.
NOTE: THE SELECT PARAMETERS SETTINGS ARE ONLY USED IF YOU ARE EXECUTING A
SELECT COMMAND! Otherwise, you can ignore these settings.
11. Press OK to return to the SQL Trigger Block dialogue box. In the Next Block field, add the
name of the SQD block that will be chained to this block. The SQD block will specify which FIX
database tags will hold values retrieved from the relational database, as well as which tags will be
used to send data to the database.
12. Add SQD block named in the SQT's Next Block field. We will configure this block to INSERT
data into the relational database table. Data sent to the relational database can be used in 2 ways:
To INSERT or change (UPDATE) values in the table, OR to specify which rows of the table will be
SELECT'ed or DELETE'd from the relational database. We will be using it in the first way, for this
example. Note: The SQD block is also used to specify which database tags will hold values
returned when a SELECT command is executed.
13. Enter a tag name for the SQD block.
14. In Tag.Field box, enter the name of the FIX tag and field, which holds the value that will be
written to the relational database table. It is important to know what type of data is expected in
this column of the relational database. If the column expects ASCII data, be sure to use an A_
field. If the column expects numeric data, then this must be an F_ field. In this example, COL2 of
TBL1 is configured as a Number, so you must use an F_ field. I suggest creating an AO or AI block
that uses the SIM driver, and specifying this tag with the F_CV field. (An AO may be better to
use, as you can change the value easily. An AI in Manual mode would work the same way.)

Actions required to Configure SQL in iFIX

Part 3: Configuring SQL Database Blocks (cont.)


15. Now, we must specify the Direction of the data transfer. This tells the SQD block whether the
tag specified in the Tag.Field entry is sending data OUT to the database table, or receiving it IN
from the database table. Since we are performing an INSERT into the table, select OUT for this
setting.
16. Using the Reset To field, we can tell the FIX database what to do with the Tag.Field value when
the SQT and SQD chain executes. An entry of NONE will not change the value of the Tag.Field.
If the field is an A_ value, using BLANK will remove all text data from this field of the specified
block. If the field is numeric ( F_ ) then using ZERO will write '0' to the specified Tag.Field. In
this example, use NONE. The only other option is ZERO, since this is a F_ field.
17. Press OK to exit the SQD block configurator.
18. Make sure that you have created the 2 other blocks that were specified in the SQT and SQD:
One tag which was specified in the Event Tag field of the SQT, and the tag which was specified in
the Tag.Field of the SQD. Once this has been done, save and reload the database.
19. Now ready to execute the SQL command using the SQT and SQD blocks. The easiest way to do
this is to create a picture, which has the following links:
Event Tag value from the SQT (in order to change the value, thus causing the SQT to
trigger)
Tag.field specified in the SQD block (in order to change the value being written to the
database)
A_DBERR field of the SQT block (to see if errors occur when the SQT is executed. A
value of '0' means that all is OK)
20. Open this picture in View and make sure there is a value for the first 2 links listed above. If
not, make sure they are on-scan, etc.
21. Write a value to the Event Tag link. You should hear your hard drive working shortly
thereafter. Switch to the SQL Task window to make sure that the command is executing properly.
You should see the SQL command echoed in the SQL Task window. If any error messages appear,
then the command didn't execute properly. Read the error and try to determine what part of the
configuration may have caused the problem.