Create a CSV based off of a query

0 votes
asked Apr 5, 2018 by maria-j-3133 (180 points)
How can I create a CSV file based on a query results?

I currently have an interface that begins with a DB query. That generates information I need to put into a CSV file.

3 Answers

+1 vote

Query results are returned as a CSV message type.  The results can be grouped by row and you can determine how many rows will be included in the message sent through the channel.  If you want to create a new message for each row of data returned by the query, set the '# of rows to include in each group' to 1.  If you want to create a single message for all rows of data, set the '# of rows to include in each group' to 'all'. 

The link below explains how to use the data from the CSV message.

answered Apr 5, 2018 by terrie-g-7436 (3,950 points)
0 votes

If your Source Node is of type Database Query you can output the results from the Query as CSV on the destination node by just specifying it as a file. This because the result of the Database Query in QIE is formatted as a CSV message model type.

answered Apr 5, 2018 by gary-t-8719 (14,420 points)
0 votes
The set up below did not work for me. The output csv was always blank. I added the following bit of mapping logic and it worked great:

//set message to csv
message = qie.createCSVMessage(true, '"', ',', 'UTF-8', true);
//set the query results to the message
message.setEndOfLine('\r\n'); //Add the CR/LF to the end of each line
message.setNode('/', source);
answered Aug 25, 2021 by jack-s-8906 (140 points)