从 JDBC 执行 Sybase 过程时,出现以下错误:
Execute cursor is declared on a procedure which contains a non-SELECT or a SELECT with COMPUTE clause. for the declaration of this cursor to be legal it should have a single select statement without a compute clause
我正在使用 JCONN4 sybase jar。 sybase 是否对程序有这样的限制,没有带有计算子句的选择语句?
我也在 Sybase 文档中搜索过,但没有得到正确的答案。
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.39996_1250/html/svrtsg/svrtsg348.htm
我不能在这里发布程序,但我可以发布示例
create proc sample (@value_date datetime = null) as
begin
if @value_date is null
select @value_date = some_column from some_table
select a,b,c,d into #ad
from
table_a where a='something'
select a,b,c,d case when a=0 then 0 else b/a
from #ad
end
使用 sybStatemt.executeQuery 函数调用上述过程
看起来像它的 Sybase 错误。重现问题的步骤
语句.setFetchSize(1000);
现在的问题是 Sybase 真的有这些限制,还是只针对他们的驱动程序,我们可以说它的驱动程序问题?
最佳答案
您必须使用 CallableStatement调用存储过程时
If you execute a stored procedure in a CallableStatement object that represents parameter values as question marks, you get better performance than if you use both question marks and literal values for parameters. Also, if you mix literals and question marks, you cannot use output parameters with a stored procedure.
The following example creates sp_stmt as a CallableStatement object for executing the stored procedure MyProc:
CallableStatement sp_stmt = conn.prepareCall( "{call MyProc(?,?)}");
The two parameters in MyProc are represented as question marks. You can register one or both of them as output parameters using the registerOutParameter methods in the CallableStatement interface.
In the following example, sp_stmt2 is a CallableStatement object for executing the stored procedure MyProc2.
CallableStatement sp_stmt2 = conn.prepareCall( {"call MyProc2(?,'javelin')}");
关于java - 从 JDBC 执行 Sybase 过程时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61211557/