I have a flow that receives csv files throughout the day... I need to take those files and add the information from them into a database table... I wrote a script that formats the csv in a way thats ready to be inserted into a sql insert statement and then save that to private data... When I hit the database module my sql statement is this...
INSERT INTO Table
VALUES
[Job.PrivateData:Key="data"]
before the file hits the database module the private data is formatted properly, after it goes through it fails because the module has added an extra single quote for every single quote that already exists...?
Here is a copy of the script prior to going to the database module...
Code: Select all
function jobArrived( s : Switch, job : Job )
{
var pdname1 = s.getPropertyValue('pdname');
var fileInfo = File.read(job.getPath(), "UTF-8");
file2 = fileInfo.replace('"scfid","opcode","scandate","barcode","servicetypeid","mid","trackingid","postnet","datereceived","jobid","jobsplitid"\r\n','(');
file2 = file2.replace(/\"/g, "'");
file2 = file2.replace(/\r\n/g, "),\r\n(");
file2 = file2.substring(0, file2.length - 4);
file2 = file2 + ";"
job.setPrivateData(pdname1,file2);
job.sendToSingle(job.getPath())
}
Thanks,
Anthony