Can you write all the results from a dbquery to a csv without setting individual nodes of the CSV?

0 votes
asked May 9, 2017 by alexa-p-6678 (150 points)
I am writing a database query and returning the object resultQuery within the mapping. From what I've read, that data is returned as a CSVmessagemodel. I am creating a new CSV message and I would like to write the output of that resultQuery to the new message. Is there a way this can be done?

1 Answer

0 votes
Best answer

You can do this with a source node set to dbQuery or through a mapping.

To do this with the source node and visual Channel editor:

For the source node set your format to "DB Query" and the incoming message and source will be a CSV message. Just set the destination to file and you have your CSV file

To do this in a mapping use the following code.

// run query and get results as csv message model.
var queryResults = qie.doQuery('dbConnectionName',
   'select * from someTable');
//set message to csv
message = qie.createCSVMessage();
//set the query results to the message
message.setNode('/', queryResults);

answered May 9, 2017 by brandon-w-8204 (33,270 points)
edited May 9, 2017 by brandon-w-8204