dbNonQuery
Version 24.2.9039
Version 24.2.9039
dbNonQuery
Executes a non-query against the database. Only action
SQL statements are supported. SQL statements that can return results are not supported.
必要なパラメータ
- driver:クロスプラットフォーム版ではJDBC ドライバーのクラス名、.NET 版ではADO.NET プロバイダー名。
- conn:接続文字列、またはデータベースURL。
- query:SQL クエリ文字列。Only the following SQL statements are supported: (CREATE, ALTER, DROP, INSERT, UPSERT, UPDATE, DELETE).
オプションのパラメータ
- commandtimeout:CommandTimeout, in seconds, for the operation to complete. Zero (
0
) means no timeout. The default is60
. - 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:クライアント側で検証や構文修正を行うのではなく、クエリをas-is でオペレーションに渡します。
- enforceparameterizedquery:Boolean (true/false) used to enforce the parameterized verification for the SQL statement. The default is
true
.
アウトプット属性
- db:affectedrows:The number of rows affected as a result of the query.
- db:result:The status of the query execution.
例
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>