While executing Sybase procedure from JDBC, I am getting below error:
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
I am using JCONN4 sybase jar. Does sybase has such restrictions on procedure to not have select statement with compute clause?
Also I searched in Sybase documentation but couldn't get proper answer.
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.39996_1250/html/svrtsg/svrtsg348.htm
I cannot post the procedure here, but I can post the sample
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
The above procedure is called using sybStatemt.executeQuery function
Looks like its Sybase bug. steps to reproduce the issue
Create a procedure having select with compute clause as i described above
write jdbc program and use belew method statement.setFetchSize(1000);
Execute the program and you will see the error
now the question is does Sybase really has these kind of restrictions or it is specific to their Driver only and we can say its driver issue ?
execute()
instead ofexecuteQuery
and handle update counts and result sets based on the boolean return value, and usegetMoreResults()
to move to next result (again update count or result set), or maybe you need to addset nocount on
at the start of your procedure. – Allencase
statement seems to be missing anend
, and it may need an explicit alias. – Allen