dbNonQuery

Version 23.4.8839


dbNonQuery


Executes a non-query against the database. Only action SQL statements are supported. SQL statements that can return results are not supported.

Required Parameters

  • driver: The JDBC driver class name in the cross-platform edition or the ADO.NET provider name in the .NET edition.
  • conn: The connection string or database URL.
  • query: The SQL query string. Only the following SQL statements are supported: (CREATE, ALTER, DROP, INSERT, UPSERT, UPDATE, DELETE).

Optional Parameters

  • commandtimeout: CommandTimeout, in seconds, for the operation to complete. Zero (0) means no timeout. The default is 60.
  • paramname#: The parameter names.
  • paramvalue#: The parameter values.
  • paramtype#: The parameter types.
  • transactionid: The Id of the transaction. This parameter is used in conjunction with the dbBeginTransaction and dbEndTransaction operations.
  • querypassthrough: Pass the query to the operation as-is instead of performing client-side validation and syntax correction.
  • enforceparameterizedquery: Boolean (true/false) used to enforce the parameterized verification for the SQL statement. The default is true.

Output Attributes

  • db:affectedrows: The number of rows affected as a result of the query.
  • db:result: The status of the query execution.

Examples

This example executes a CREATE statement against the target database to create a table and various column definitions.

<!-- Setting the input db item and attributes -->
<arc:set attr="db.driver" value="cdata.jdbc.mysql.MySQLDriver" />
<arc:set attr="db.conn" value="jdbc:cdata:mysql:server=localhost;port=3306;database=sakila;user=root;password=Password123;"/>
<arc:set attr="db.query" value="CREATE TABLE Neighbors (PersonID int,LastName varchar(255),FirstName varchar(255),Address varchar(255),City varchar(255));"/>

<!-- Calling the operation, passing in the db item and setting an output item -->
<arc:call op="dbNonQuery" in="db" out="results" >
  <!-- optional logging step to see the output attributes of the query in the application log -->
  <arc:set attr="_log.info" value="[results.*]" />
</arc:call>

This example executes a parameterized INSERT statement against the target table:

<!-- Setting the input db item and attributes -->
<arc:set attr="db.driver" value="cdata.jdbc.mysql.MySQLDriver" />
<arc:set attr="db.conn" value="jdbc:cdata:mysql:server=localhost;port=3306;database=sakila;user=root;password=Password123;"/>
<arc:set attr="db.query" value="INSERT INTO Neighbors (PersonID, LastName, FirstName, Address, City ) VALUES (@param1, @param2, @param3, @param4, @param5);"/>
<arc:set attr="db.paramname#1" value="param1" />
<arc:set attr="db.paramvalue#1" value="1" />
<arc:set attr="db.paramname#2" value="param2" />
<arc:set attr="db.paramvalue#2" value="Bobby" />
<arc:set attr="db.paramname#3" value="param3" />
<arc:set attr="db.paramvalue#3" value="Ricky" />
<arc:set attr="db.paramname#4" value="param4" />
<arc:set attr="db.paramvalue#4" value="26 Wonder Bread Lane" />
<arc:set attr="db.paramname#5" value="param4" />
<arc:set attr="db.paramvalue#5" value="Charlotte" />

<!-- Calling the operation, passing in the db item and setting an output item -->
<arc:call op="dbNonQuery" in="db" out="results" >
  <!-- optional logging step to see the output attributes of the query in the application log -->
  <arc:set attr="_log.info" value="[results.*]" />
</arc:call>