web stats
How can I cancel the file writer when no data is returned? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 12-09-2015, 04:31 AM
GaryK GaryK is offline
What's HL7?
 
Join Date: Dec 2015
Posts: 1
GaryK is on a distinguished road
Default How can I cancel the file writer when no data is returned?

I am using a Mirth Channel to read data in from sql server and then output the data as CSV file into specific folder using a destination and a transformer.

Destination sets the output folder and file name and the transformer is a javascript that fetches the data from SQL server and formats the data.

How can I cancel the file writer when no data is returned?

Code:
var dbConn = databaseConnectionFactory.createDatabaseConnection('net.sourceforge.jtds.jdbc.Driver','jdbc:jtds:sqlserver://<IPaddress>:1433/<DB>','<user>',<password>');

var result1 = dbConn.executeCachedQuery("exec [z_stored_proc] 'Parameter1'");
while(result1.next())
{
   tmp.row += <row>
   <LastName>"{result1.getString('LastName')}"</LastName>
   </row>; 
}
Using Mirth Connect Server 3.2.0.7628
Thanks
Gary K
Reply With Quote
  #2  
Old 12-09-2015, 06:57 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,123
narupley is on a distinguished road
Default

Well, you could move some of that logic into the filter. That way you can just return false if you find no results. The executeCachedQuery method returns a CachedRowSet, so you can just call size() on it and verify it's greater than zero. Then to pass it on to the transformer, you could put it in the connector/channel map, or you could just declare it as a global scope variable by removing the "var " in front of the declaration.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
Reply

Tags
file writer

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 08:54 PM.


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