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

# dbCall

> 在資料庫中執行預存程序。

export const siteNameShort = "知行之橋";

在資料庫中執行預存程序。

## 必需的參數

* **driver**：跨平臺版本中的 JDBC 驅動程式類名稱，或 .NET 版本中的 ADO.NET 提供程式名稱。
* **conn**：連接字串或資料庫 URL。
* **sp**：預存程序的名稱。

## 可選的參數

* **commandtimeout**：操作完成的命令逾時時間（以秒為單位）。零 (0) 表示沒有逾時。預設值為 `60`。
* **paramname#**：參數名稱。
* **paramvalue#**：參數值。
* **paramtype#**：參數型別。
* **fromrow**：從開頭要跳過的行數。預設值為 `0`。
* **maxrows**：從資料庫傳回的最大行數。設定為 `-1`（預設值）可取得所有結果。
* **querypassthrough**：將查詢按原樣傳遞給操作，而不是執行用戶端驗證和語法糾正。

## 輸出屬性

* **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;"/>
```
