Question

I want to add parameter in database query in mirth then how to do?

i am using following method to execute query in database.

dbConn.executeUpdate('sql query');
Was it helpful?

Solution

var params = new java.util.ArrayList();
params.add($('lastName'));
params.add($('firstName'));
params.add($('middleName'));


var expression = "INSERT INTO hl7_test_sample (patient_last_name, patient_first_name, patient_middle_initial) VALUES (?, ?, ?);"
var result = dbConn.executeUpdate(expression, params);

I am using Mysql database.

ref: http://www.mirthcorp.com/community/forums/showthread.php?t=894

OTHER TIPS

We can use Lists to add parameter in query. Please check the following code :-

var params = Lists.list().append($('lastName'));
params.append($('firstName'));
params.append($('middleName'));


var expression = "INSERT INTO hl7_test_sample (patient_last_name, patient_first_name, patient_middle_initial) VALUES (?, ?, ?);"
var result = dbConn.executeUpdate(expression, params);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top