0

在 Volt DB 存储过程中运行选择查询时出现运行时错误。当我在 volt DB web studio 中运行选择查询时,一切都很好。错误如下:

错误:VOLTDB 错误:意外失败:java.lang.RuntimeException:VoltTableRow 处于无效状态。考虑调用AdvanceRow()。在 org.voltdb.VoltTableRow.validateColumnType(VoltTableRow.java:752) 在 org.voltdb.VoltTableRow.getDouble(VoltTableRow.java:384) 在程序.testPrcUpdateConstraint.run(testPrcUpdateConstraint.java:93) 在 sun.reflect.NativeMethodAccessorImpl。在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java: 43) 的 invoke0(Native Method) 606) 在 org.voltdb.ProcedureRunner.call(ProcedureRunner.java:316) 在 org.voltdb.iv2.ProcedureTask.processInitiateTask(ProcedureTask.java:111) 在 org.voltdb.iv2.MpProcedureTask.run(MpProcedureTask.java:157) ) 在 org.voltdb.iv2.MpRoSite。

关于可能出了什么问题的任何指示都会非常有帮助。

4

1 回答 1

3

由此看来,存储过程中的 SQL 很好,但您试图从 VoltTable 的特定行访问一些值,而无需先将其推进到第一行。VoltTable 有一个指向“当前行”的内部指针,该指针最初根本不指向任何行。

例如,如果您知道 VoltTable 只有一行,您可以执行以下任何操作:

// most efficient, moves the pointer to the next row
table.advanceRow();
String col1 = table.getString(0);

或者

// moves the pointer to an arbitrary row, less efficient for iterating
table.advanceToRow(0);
String col1 = table.getString(0);

或者

// least efficient - makes a new copy of the row
VoltTableRow row = table.fetchRow(0);
String col1 = row.getString(0);

在VoltTable的 Javadoc 页面上有一个示例。这是遍历 VoltTable 的行的最常见的习惯用法:

while (table.advanceRow()) {
    System.out.println(table.getLong(7));
}

AdvanceRow() 和 AdvanceToRow(int rownumber) 方法来自VoltTableRow,它是 VoltTable 的扩展。VoltTable 的 fetchRow(int rownumber) 方法将该行的副本作为新的 VoltTableRow 对象返回,该对象仅包含它已经指向的一行数据。

于 2015-01-13T20:11:36.760 回答