web stats
Created SQL string issue - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-23-2019, 01:48 AM
stenhoeve stenhoeve is offline
Mirth Newb
 
Join Date: Jan 2014
Posts: 8
stenhoeve is on a distinguished road
Question Created SQL string issue

Hello,

I have an issue with the SQL string that is being crearted in Mirth Connect.

The code below gives issues in SQL.

var studyDate = channelMap.get('studyDate')
var sqlQuery = "INSERT INTO sr_entries_1 (StudyDate) VALUES ('" + studyDate + "')";
var result = dbConn.executeUpdate(sqlQuery);

It returns the error:

Msg 8152, Level 16, State 14, Line 1
String or binary data would be truncated.
The statement has been terminated.

In the SQL profiler I see that the sql string look like below (with an "enter" before the last ':

INSERT INTO sr_entries_1(StudyDate) VALUES ('20180710
')

If I change this string manually like below than I don't get this error message.

INSERT INTO sr_entries_1(StudyDate) VALUES ('20180710')

How can I prevent this from happening, so the sql string must not have a "enter" before the last ' ?
Reply With Quote
  #2  
Old 05-23-2019, 02:45 AM
stenhoeve stenhoeve is offline
Mirth Newb
 
Join Date: Jan 2014
Posts: 8
stenhoeve is on a distinguished road
Smile

Issue has been solved. I looked at the file (using notepad++) that I reading with a file reader to populate my variables. Each line has a CR and LF so that was the issue.

Using a string replace I "removed" the CR and LF

string.replace(/[\r\n]/g, '');
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 07:45 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation