Skip to content

pQuery.doUpdateQuery

Signature: pQuery.doUpdateQuery(connection, useReadOnlyConnection*, timeoutSeconds*)

Returns: Integer updateCount - either the row count for SQL statements such as INSERT, UPDATE or DELETE, or 0 for SQL statements that return nothing

Execute a parameterized database query and return the number of rows touched by the parameterized query.

Note

This method uses the java.sql.PreparedStatement.executeUpdate() method. You will usually use the qie.doQuery() and qie.doConditionQuery() methods. Some JDBC drivers will require you to use this java.sql.PreparedStatement.executeUpdate() method instead.

Parameters

Type Name Description Default
String connection the name of the database connection
Boolean useReadOnlyConnection* (optional) use a read-only database connection false
Integer timeoutSeconds* (optional) the SQL query timeout in seconds; 0 means no timeout 0

Example

// Create the pQuery object with the query to be executed
var pQuery = qie.getParameterizedQuery("update patient\n" +
   "set balance = 100\n" +
   "where name = 'Diana'");

// Execute thequery
var queryResult = pQuery.doUpdateQuery("EMR Database"); // queryResult = number of rows affected or 0