web stats
Mirth Community - View Single Post - Adding Header into CSV file
View Single Post
  #5  
Old 10-29-2018, 05:50 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 715
agermano is on a distinguished road
Default

If you are doing aggregate results, that means your entire query will produce a single message.

See this thread for how to quickly convert database reader input to delimited text output in a transformer: https://www.mirthcorp.com/community/...d.php?t=217724

Your csv headers are just another row of data to the serializer. After the results are converted in the previous step (or you manually construct tmp) you can insert a new row at the beginning of your outbound variable that contains your headers (which can be grabbed from msg children.)

You can do the same thing if you aren't using aggregate results, but then you must be able to know which row of the result set you are on, so that you only insert the headers before the first row.

I recently opened a request to make that information available in the sourceMap as it is for File Readers. You can vote for it if you think it would be beneficial to you: http://www.mirthcorp.com/community/i...wse/MIRTH-4334

In oracle, you can add ROW_NUMBER() as a column in your query so that you can check if you are on the first row of the results. https://docs.oracle.com/cd/B19306_01...nctions137.htm
Reply With Quote