How to write text or csv files
Writing a CSV file
// open the CSV file, in order to write into it
var fileId = utils.openCSVFile(
"ab.csv",true,9, ",",true,
["userCodeId","password","rowVersion","dateExpirationPassword"],
[null,null,null,null]
);
// declare a callback function, invoked by a SQL query, used to write a single line into the CSV file
var processRow = function(jsonRow) {
utils.writeToCSVFile(fileId,jsonRow);
}
// execute the SQL query, whose result set will be read row by row, by invoking each time the specified callback
utils.executeQueryWithCallback(
"processRow", // callback function, invoked for each record coming from the query, whose argument will receive a JSON object representing the record
"SELECT U.USER_CODE_ID,U.DESCRIPTION,U.PASSWORD,U.DATE_EXPIRATION_PASSWORD,U.ROW_VERSION FROM PRM01_USERS U",
null,
false,
true,
[]
);
// close the CSV file, after reading all records from the query
utils.closeCSVFile(fileId);Writing a text file
Optimizing writing a csv file, starting from a SQL query
PreviousHow to read a text or csv file and save data on the databaseNextReading an xls file stored in the specified path
Last updated