> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arc.cdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# dbNonQuery

> CREATE、INSERT、UPDATE、DELETE など、結果を返さないSQL アクションステートメントをデータベースに対して実行します。

データベースに対して非クエリを実行します。サポートされるのは`action` SQL ステートメントのみです。結果を返すことができるSQL ステートメントはサポートされません。

## 必要なパラメータ

* **driver**: クロスプラットフォーム版ではJDBC ドライバーのクラス名、.NET 版ではADO.NET プロバイダー名。
* **conn**: 接続文字列、またはデータベースURL。
* **query**: SQL クエリ文字列。サポートされるSQL ステートメントは次のみです：（CREATE、ALTER、DROP、INSERT、UPSERT、UPDATE、DELETE）。

## オプションのパラメータ

* **commandtimeout**: オペレーションが完了するまでのCommandTimeout（秒）。ゼロ（`0`）はタイムアウトなしを意味します。デフォルトは`60` です。
* **paramname#**: パラメータ名。
* **paramvalue#**: パラメータ値。
* **paramtype#**: パラメータの種類。
* **transactionid**: トランザクションのId。このパラメータは、[dbBeginTransaction](./op-db-begin-transaction)および[dbEndTransaction](./op-db-end-transaction)オペレーションと組み合わせて使用します。
* **querypassthrough**: クライアント側で検証や構文修正を行うのではなく、クエリをas-is でオペレーションに渡します。
* **enforceparameterizedquery**: SQL ステートメントのパラメータ化された検証を強制するために使用するブール値（true/false）。デフォルトは`true` です。

## アウトプット属性

* **db:affectedrows**: クエリの結果として影響を受けた行数。
* **db:result**: クエリ実行のステータス。

## 例

この例では、ターゲットデータベースに対してCREATE ステートメントを実行し、テーブルとさまざまなカラム定義を作成します。

```xml theme={null}
<!-- 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>
```

この例では、ターゲットテーブルに対してパラメータ化されたINSERT ステートメントを実行します：

```xml theme={null}
<!-- 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>
```
