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