Skip to content

qie.doConditionQuery

Signature: qie.doConditionQuery(connection, query, timestampFormat*, timeoutSeconds*)

Returns: Object scalarValue - the typed value of the first column of the first row of the result set, or null when no row matched

Execute a database query and return the value of the first column of the first row of the result set. All other columns and rows are ignored.

Note

This method uses the java.sql.PreparedStatement.execute() method.

Note

When no row matches, null is returned, which makes this the natural call for an existence check.

Parameters

Type Name Description Default
String connection the name of the database connection
String query the SQL query statement to execute (may contain node tags to be evaluated)
String timestampFormat* (optional) the format string to use for timestamp fields yyyyMMddHHmmss
Integer timeoutSeconds* (optional) the SQL query timeout in seconds; 0 means no timeout 0

Example

// a matching row returns the first column of that row
var typedValue = qie.doConditionQuery("EMR Database", "select name, date_of_birth as dob from patient where patient_id = 1"); // "Ada Lovelace"

// no matching row returns null, which makes this the natural existence check
if (qie.doConditionQuery("EMR Database", "select 1 from patient where patient_id = 999") != null) {
   // the patient exists
}