web stats
Table name in DatabaseWriter - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 06-13-2014, 02:17 AM
lordc001 lordc001 is offline
What's HL7?
 
Join Date: Apr 2014
Posts: 5
lordc001 is on a distinguished road
Default Table name in DatabaseWriter

I have the smallest of problems but i can't seem to figure it out.

Basically i have a FileReader channel which reads a Delimited text file and puts the contexts into a globalMap variable.

The problem is that i have to use that variable as the table name in a DatabaseWriter channel, i pull the value from the global map.

INSERT INTO ${pname} (id, messageid,OID, ReceivedDateTime,....

when i try to insert the data i get the following message.

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorEx ception: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Demo' SET AutomatedTestResult, Demo is the Value I pulled from the globalMap

Which means that the query sent looks a bit like this:

Insert into 'Demo' (...)

I assume that the error are the quotations on the word Demo, but i cant seem to figure out how to remove them. i have tried using ReplaceAll but i just cant figure it out.

Any and all help is greatly apreciated.

Last edited by lordc001; 06-16-2014 at 03:31 AM.
Reply With Quote
  #2  
Old 06-16-2014, 06:42 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,119
narupley is on a distinguished road
Default

Unfortunately in that case, you'll have to use JavaScript mode instead. In SQL mode, the ${varName} replacements are only supported for expressions (like values in a WHERE clause), not for identifiers like table names. I've created an issue for this: MIRTH-3343
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #3  
Old 06-16-2014, 06:55 AM
lordc001 lordc001 is offline
What's HL7?
 
Join Date: Apr 2014
Posts: 5
lordc001 is on a distinguished road
Default

Ah ok, thanks for the answer, I'll start looking into that.

Would a Javascript Writer connector work in this case?
Reply With Quote
  #4  
Old 06-16-2014, 07:16 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,119
narupley is on a distinguished road
Default

Quote:
Originally Posted by lordc001 View Post
Ah ok, thanks for the answer, I'll start looking into that.

Would a Javascript Writer connector work in this case?
Yes, a JavaScript Writer or Database Writer in JavaScript mode would both work.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
Reply

Tags
database

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 08:08 AM.


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