Mirth – DB Reader

In the Mirth tool, often people face many issues when it comes to connecting to DB either fetching data or updating/inserting data. This blog post will help you understand what are functions used for what purposes.

Starting with the Database reader concept, there are multiple misconception that needs to be clarified. Not everything are understood as the name portrays, the tool has its own definition of most of the areas and buttons.

polling settings

The option Poll Once on Start means that the database channel will start to poll the database once it is deployed. In-case if NO is selected for this option then, the channel will start to fetch the data from the database in the specified interval of time.

batchprocess

The option Process Batch is used, when the data are coming in batches and there is a necessity to split the data into separate batches. You may wonder, how data will come in batch from the database?. Seems there is a option available to make such polling of data from the DB. In that case you will select YES for the Process Batch and the split the incoming. In usual case, the option NO has to be selected.

connectionstring

Please note that the URL tab for SQL Server will be different than other traditional relational databases. Instead of IP & port in the connection string we may need to use the SQL server name or the system name. When you assign the special or custom user (sa in this example) specific to certain database then your port number will not be the usual default SQL server database port (i.e 1443). To check the port number that you are accessing the data use the following query.

USE master
GO
xp_readerrorlog 0, 1, N’Server is listening on’
GO

Apart from this, the other major misconception is the usage of Javascript. This will be either YES or NO. But in either case we just have to remember one thing that, this will be the triggering action that will be performed on the database. Mirth will poll the database by using the query that we write in the below area.

sql javascript

You can either use this SQL javascript area just for triggering the database by using a query, and perform the logic inside the transformers. Else some people prefer to write logic in the connector area itself by pressing YES on the using Javascript radio button.

But, if you decide to write logic in the SQL javascript area in the source, you will have to face certain limitations. Like the following:

  1. The variable used inside the SQL javascript text area cannot be used in the next javascript text area (i.e  Post-processor javascript). So just in-case you have to update a data using the data fetched previously the SQL javascript area, it will not work well.
  2. You do not have the liberty of using channelMap variable inside the SQL javascript editor area, neither the globalMap. In both the cases it will throw error.
  3. Said that, the result set value will be returned to the source transformer which can be used to process the data of our interest.

Most, misconception of all is how can we fetch data (i.e process). Mirth will fetch data from the Database only in the one-by-one row manner. There is no such possibility available in mirth to fetch 10 or 15 or 100 rows in single stretch. It’s Mirth a tool, not hulk. 🙂

Hope it clarifies some questions.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: