java之从 JDBC 执行 Sybase 过程时出现问题
从 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')}");
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。