dbCall

Version 23.4.8843


dbCall


在数据库中执行存储过程。

必需的参数

  • conn:连接字符串或数据库 URL。
  • sp: 存储过程的名称。

可选的参数

  • commandtimeout: 命令超时,以秒为单位完成操作。零(0)表示没有超时。默认值为 60
  • paramname#:*: 参数名称。
  • paramvalue#: 参数值。
  • paramtype:*: 参数类型。
  • fromrow: 从开始要跳过的行数。默认值为 0
  • maxrows: 从数据库返回的最大行数。设置为-1可获取所有结果。默认值为 -1
  • querypassthrough:将查询按原样传递给操作,而不是执行客户端验证和语法纠正。

输出属性

  • db:\: 输出因存储过程而异。

示例

此示例使用跨平台版本的知行之桥在 MySQL 数据库中执行存储过程。

<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" />

只要在安装并运行知行之桥的计算机上安装驱动程序,就可以修改上面的示例以定位其他数据库。 针对 .NET 调整此示例将涉及更改 driverconn 输入,如下所示:

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