web stats
Database to Database Example - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-12-2015, 05:22 AM
themochael themochael is offline
OBX.2 Kenobi
 
Join Date: Sep 2013
Posts: 54
themochael is on a distinguished road
Default Database to Database Example

Does anyone have a Database to Database example? I am using Mirth 3.2.2.7694 and pulling data from a MS SQL Server database (datareader) and inserting into a downstream (datawriter). Any advice would be helpful
Reply With Quote
  #2  
Old 08-12-2015, 06:28 AM
themochael themochael is offline
OBX.2 Kenobi
 
Join Date: Sep 2013
Posts: 54
themochael is on a distinguished road
Default

More details. In my Source, i have JavascriptReader:
var dbConn = DatabaseConnectionFactory.createConnection('net.so urceforge.jtds.jdbc.Driver', 'jdbc:jtds:sqlserver://localhost:1433/MASTERADDRESS;instance=MSSQL', 'USERNAME', 'PASSWORD');
var query = "SELECT (case when [Address 2] = '' then [Address 1] else ([Address 1]+', '+[Address 2])end) as 'Address'FROM [MASTERADDRESS].[dbo].[ADDRESS]"

dbConn.executeUpdate(query);
dbConn.close();

In my database writer, what would i put in the VALUES() section?
Reply With Quote
  #3  
Old 08-12-2015, 06:29 AM
vpnath vpnath is offline
OBX.1 Kenobi
 
Join Date: Jun 2010
Posts: 36
vpnath is on a distinguished road
Default

What's the issue you are having? Seems like it would be pretty straight-forward. Your data from the database reader query will be passed as variables to your DB writer destination. Then you just plug those variables into your INSERT statement for your destination DB.
Reply With Quote
  #4  
Old 08-12-2015, 06:37 AM
themochael themochael is offline
OBX.2 Kenobi
 
Join Date: Sep 2013
Posts: 54
themochael is on a distinguished road
Default

how do i set those variables? Sorry, if the data was delimited or something, I would totally get it.
Reply With Quote
  #5  
Old 08-12-2015, 06:55 AM
vpnath vpnath is offline
OBX.1 Kenobi
 
Join Date: Jun 2010
Posts: 36
vpnath is on a distinguished road
Default

In the Source transformer for your database reader, use Tag mapper to map your query results to variables and add them to your Channel Map. Your query output should be available in your message tree on the right and you can just drag the appropriate fields to the appropriate variable mapping.

These variables will be available then in your DB writer destination. For example, if you mapped a variable called 'address', you can access it in your destination by calling $('address').
Reply With Quote
  #6  
Old 08-12-2015, 07:28 AM
themochael themochael is offline
OBX.2 Kenobi
 
Join Date: Sep 2013
Posts: 54
themochael is on a distinguished road
Default

OK - i follow now. Last follow up question. Should i be alarmed that the value in the template tree is coming back as "Value"?
Reply With Quote
  #7  
Old 08-12-2015, 07:37 AM
vpnath vpnath is offline
OBX.1 Kenobi
 
Join Date: Jun 2010
Posts: 36
vpnath is on a distinguished road
Default

Yes, that's fine. The value will get populated dynamically with your query output. Good luck!
Reply With Quote
Reply

Tags
datareader, datawriter

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 07:43 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation