Replies: 2 comments 1 reply
-
You might consider calling your query to return JSON since you can return the entire result set in one query, no need to run multiple selects. Also, you can COALESCE the SQL return value to return an empty array if no results - so you always return a result, there is then no need to then check for size (i.e. just call result.next() and JSON.parse the returned value from the query). You should also consider using a cached db connection, see: https://github.com/pacmano1/Mirth-Snippets/blob/main/executeSharedDBStatement.js |
Beta Was this translation helpful? Give feedback.
-
Three things I noticed. First, you probably shouldn't be using a SELECT * in any query. Just select what you need. Second, your getString() indexes are incorrect when assigning your First/Last name variables. Third, your CSV channel map is being overwritten by your While loop, which is why you only get the last row of your query. Below is a tweaked and formatted version of your script:
|
Beta Was this translation helpful? Give feedback.
-
I am trying to generate a CSV file from rows returned by a select query on the source transformer. Here are the steps I want to perform:
However, each time I execute the channel, the resultant CSV only has the row returned by the last query inside the while loop.
Am I doing something wrong while passing the CSV in transformer step? Any expert suggestion will be highly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions