Database Module adding extra single quotes...???

Post Reply
apietrocini
Member
Posts: 32
Joined: Fri Mar 24, 2017 7:06 pm
Location: Cleveland, OH

Database Module adding extra single quotes...???

Post by apietrocini »

Hello all!

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())	

}
Any thoughts...?

Thanks,

Anthony
apietrocini
Member
Posts: 32
Joined: Fri Mar 24, 2017 7:06 pm
Location: Cleveland, OH

Re: Database Module adding extra single quotes...???

Post by apietrocini »

Private data before database module..
Screen Shot 2020-02-27 at 11.11.46 AM.png
Screen Shot 2020-02-27 at 11.11.46 AM.png (246.46 KiB) Viewed 4553 times
apietrocini
Member
Posts: 32
Joined: Fri Mar 24, 2017 7:06 pm
Location: Cleveland, OH

Re: Database Module adding extra single quotes...???

Post by apietrocini »

SQL statement being passed from database module...
Screen Shot 2020-02-27 at 11.15.10 AM.png
Screen Shot 2020-02-27 at 11.15.10 AM.png (135.44 KiB) Viewed 4553 times
Post Reply