IRISConnect for ODBC - irislink.com

15
An I.R.I.S. Technical Note IRISConnect for ODBC 2/24/2012 I.R.I.S. Products & Technologies lde

Transcript of IRISConnect for ODBC - irislink.com

An I.R.I.S. Technical Note

IRISConnect for ODBC

2/24/2012 I.R.I.S. Products & Technologies

lde

IRISConnect for ODBC Page 2

IRISConnect for ODBC

Project ID IRISConnectODBC

Product IRISConnectODBC

Version 1.0

Ref. PRJ–R&D # / LD # ICONN-ODBC

CD Number

From Louis Destrée

Revision History

Date Description Author

2012-02-20 First version 1.0 Louis Destrée

Reference

File Description

IRISConnect for ODBC Page 3

Contents Introduction ...................................................................................................................................... 4

Connection ......................................................................................................................................... 5

Rule Set ............................................................................................................................................. 6

Rule .................................................................................................................................................... 7

Folder and File ................................................................................................................................ 7

Insert ............................................................................................................................................. 8

Select ............................................................................................................................................ 9

Custom ......................................................................................................................................... 11

Conclusion ........................................................................................................................................ 13

IRISConnect for ODBC Page 4

Introduction The goal of this document is to describe IRISConnect for ODBC.

IRISConnect for ODBC is part of the IRISConnect family.

It can be used to:

a) Create folder(s) and copy files

b) Insert data in a database table

c) Execute other SQL statements like UPDATE, DELETE or even SELECT.

To illustrate the functionalities of IRISConnect for ODBC, we will create a configuration that can be

used to:

a) copy each invoice (with two images per invoice) in a separate folder

b) create a new row (insert) in the database making sure that this row does not already exists

(conditional insert)

The input file looks like this:

<?xml version="1.0" encoding="utf-8"?>

<input>

<field label="invoice.number">32001</field>

<field label="invoice.date">07/07/2010</field>

<field label="invoice.amount">312.12</field>

<object type="invoice" name="invoice1">

<file>input/Document1/00000001.TIF</file>

<file>input/Document1/00000002.TIF</file>

</object>

<field label="invoice.number">32002</field>

<field label="invoice.date">07/07/2010</field>

<field label="invoice.amount">234.12</field>

<object type="invoice" name="invoice2">

<file>input/Document2/00000001.TIF</file>

<file>input/Document2/00000002.TIF</file>

</object>

</input>

IRISConnect for ODBC Page 5

Connection In order to connect to an ODBC data source, you must provide a server, a username, a password and

a DSN.

For the moment, IRISConnect for ODBC only supports System DSN. These DSN should be

configured by means of the ODBC Data Source Administrator application that can be found in

c:\windows\System32\odbcad32.exe.

Please note that on a 64 bits system, you should use the 32 bits version of the ODBC Data Source

Administrator application that can be found in c:\windows\SysWOW64.

IRISConnect for ODBC Page 6

Rule Set

For each rule set, you can specify a type and / or a more complex condition. The rules belonging to

that rule set will be applied only to the input object matching the specific condition or type.

IRISConnect for ODBC Page 7

Rule There are five types of rules in IRISConnect for ODBC: folder, file, insert, select and custom.

Folder and File To create a folder and / or a file, you must provide a path and a name.

The name is the name of the object (either a folder or a file) that must be created for each input

object.

IRISConnect for ODBC Page 8

The path is the location where the object must be created (copied).

Note. If the path is empty then the path of the previous rule (in the rule set) will be used.

By means of these rules (“Folder” and “File”), the input files can be copied into a more structured

hierarchy of folders.

In our example, first we create a folder whose name is the name of the object (“invoice1” or

“invoice2”) prefixed by “test_”. After that, we copy each file in the newly created folder.

Insert An insert rule is used to create a new row in a database table. You must select a table (ex. table1),

then you can specify the input field / data that should be put in each columns.

Please note that some ODBC drivers do not provide meta-data (such as the tables, columns, etc.). In

that case, you should use a custom rule.

IRISConnect for ODBC Page 9

Select A select rule lets you query the database. You must specify the name of the table (ex. table1) and the

name of a variable which is used to store the result of the query (in our example the “exists” variable).

The value of this variable is either “true” or “false” depending if the SELECT statement returns some

row(s) or not. This variable can be used as the condition of a rule set.

There are two ways to specify SELECT parameters.

Basically, you can specify the columns that should be used in the WHERE clause of the select. Each

column must have an exact name and each column can be mapped with input field / data (in that

case, the input field value is used in the WHERE clause).

Assuming that the table “table1” has a column “test_number” and that the value of the input field

“invoice.number” is 32001, the following “setup” will be translated by:

SELECT * FROM table1 WHERE test_number=32001

IRISConnect for ODBC Page 10

Another way to achieve a similar result is to specify your own SELECT statement. In that case, each

parameter in the SELECT statement (identified by a question mark) will be replaced by the

“parameters” as defined in the first tab.

IRISConnect for ODBC Page 11

Custom Custom rules give us the ability to execute any SQL statement, not only INSERT but also UPDATE or

DELETE but of course you must have a good understanding of the SQL language.

There are two ways to configure a custom rule. The easiest one is just to specify a table (ex. table1)

and the mapping between the columns (ex. test_char and test_number) and the input field / data.

This configuration will be translated by:

INSERT INTO table1 (test_char,test_number) VALUES (’invoice1’,32001)

IRISConnect for ODBC Page 12

A much more powerful approach is to specify your own SQL statement where the question marks

will be replaced by the “parameters” specified on the first tab.

IRISConnect for ODBC Page 13

Conclusion In our example, we have created two rule sets.

The first one is in charge of copying the files (two files per document) in a structured hierarchy of

folders. Then, we did a query (a SELECT) on the database to check if a row (identified by the content

of the test_number column) already exists.

The second rule set contains an insert rule. In order to avoid duplicated entries in the database, we

have put a condition on the rule set: fields[“exists”]==”false”.

Please note that our goal was just to demonstrate the possibilities of IRISConnect for ODBC. Some

SQL database system, give us an easy way to do conditional insert, for example:

INSERT INTO table1 (test_number) VALUES (32001) WHERE NOT EXISTS

(SELECT * FROM table1 WHERE test_number=32001)

IRISConnect for ODBC Page 14

IRISConnect for ODBC Page 15