> ## 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.

# dbCall

> データベースでストアドプロシージャを実行します。

export const siteNameShort = "Arc";

データベースでストアドプロシージャを実行します。

## 必要なパラメータ

* **driver**: クロスプラットフォーム版ではJDBC ドライバーのクラス名、.NET 版ではADO.NET プロバイダー名。
* **conn**: 接続文字列、またはデータベースURL。
* **sp**: ストアドプロシージャの名前。

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

* **commandtimeout**: オペレーションが完了するまでのコマンドタイムアウト（秒）。ゼロ（0）はタイムアウトなしを意味します。デフォルトは`60` です。
* **paramname#**: パラメータ名。
* **paramvalue#**: パラメータ値。
* **paramtype#**: パラメータの種類。
* **fromrow**: 先頭からスキップする行数。デフォルトは`0` です。
* **maxrows**: データベースから返される行の最大数。すべての結果を取得するには、`-1`（デフォルト）に設定します。
* **querypassthrough**: クライアント側で検証や構文修正を行うのではなく、クエリをas-is でオペレーションに渡します。

## アウトプット属性

* **db:\\**: ストアドプロシージャによりアウトプットは異なります。

## 例

この例では、クロスプラットフォーム版の{siteNameShort} を使用して、MySQL データベースでストアドプロシージャを実行します。

```xml theme={null}
<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.sp" value="film_in_stock"/>
<arc:set attr="db.paramname#1" value="p_film_id"/>
<arc:set attr="db.paramvalue#1" value="3"/>
<arc:set attr="db.paramname#2" value="p_store_id"/>
<arc:set attr="db.paramvalue#2" value="7"/>

<arc:call op="dbCall" in="db" out="results" >
  <!-- optional logging step to see the output of the SP in the application log -->
  <arc:set attr="_log.info" value="RESULTS = [results.*]" />
  <!-- adding the result data from the stored procedure to the file that is being created and pushed out -->
  <arc:set attr="output.data" value="[results.*]" />
  <!-- setting the filename --> 
  <arc:set attr="output.filename" value="storedProcResults.txt" />
</arc:call>

<arc:push item="output" />
```

{siteNameShort} がインストールおよび実行されているマシンにドライバーがインストールされている場合に限り、上記の例を変更して別のデータベースを対象にすることができます。例を.NET 用に調整するには、`driver` と`conn` のインプットを次のように変更する必要があります：

```xml theme={null}
<arc:set attr="db.driver" value="System.Data.CData.MySql" /> 
<arc:set attr="db.conn" value="Server=localhost;Database=sakila;UID=root;Password=Password123;"/>
```
