首页 > 解决方案 > 带有数组参数的 Voltdb 存储过程

问题描述

我有一个采用字符串数组的 VoltDB 存储过程,String[]它已成功加载,但我似乎无法使用带有 exec 的 VoltDB SQL 查询接口执行存储过程。

也不能在 sqlcmd 界面中执行。

我收到此错误:

错误:PrepareStatement 错误:过程“StoredProcedure”的参数计数无效(收到:3,预期:2,)

如何构造 exec 语句以从 VoltDB 检索存储过程的结果?

标签: databasestored-proceduresvoltdb

解决方案


不幸的是,在使用 sqlcmd 接口时,没有很好的方法将数组作为参数传递。如果你需要测试这个程序,最好的方法是编写一个简单的java/python脚本来调用带有数组的程序。在 python 中,它看起来像这样:

#!/usr/bin/env python
from voltdbclient import *
client = FastSerializer("localhost", 21212)

# declare array parameters the same as primitives
fooProc = VoltProcedure( client, "Foo", [FastSerializer.VOLTTYPE_BIGINT])

# the set of all parameters is the outer array, the inner array is the parameter value
fooResponse = fooProc.call( [ [1, 2, 3, 4, 5] ] )
for x in fooResponse.tables:
   print x

全面披露:我在 VoltDB 工作。


推荐阅读