Monday, March 12, 2012

Invalid Cursor State

Hi all.
I have a procedure in my database whose code is more or less the
following:
CREATE PROCEDURE Fnt ( @.Name nvarchar(20) ) AS
declare @.number1 int;
declare @.number2 int;
CREATE TABLE #Table1
(
ValueRet int,
)
set @.number1=(select SUBSTRING( pol, 1 , 2 ) from table where (id IN
(select ref from table_set where num=@.Name)));
set @.number2=(select SUBSTRING( pol, 5 , 10 ) from table where (id IN
(select ref from table_set where num=@.Name)));
insert into #Table values (@.number1);
insert into #Table values (@.number2);
select * from #Table;
if @.@.Error <> 0
begin
return @.@.error
end
GO
The procedure runs ok within the database. I have a problem when quering
using ODBC. I run the SQLExecDirect and it returns SUCCESS. Then I run
the SQLBind instruction and it successes again. However when running the
SQLFecth I get an error Invalid Cursor State (24000), while it should
return the query values (there are values to be returned ;)) )
Does anybody knows why that happens?
Any help is really welcome.
TA.CREATE PROCEDURE Fnt ( @.Name nvarchar(20) ) AS
SET NOCOUNT ON
declare @.number1 int;
declare @.number2 int;
"George" <george.news@.NOSPANgmx.net> wrote in message
news:Xns950AD84C3ED7newsgmxnet@.213.0.184.81...
> Hi all.
> I have a procedure in my database whose code is more or less the
> following:
> CREATE PROCEDURE Fnt ( @.Name nvarchar(20) ) AS
> declare @.number1 int;
> declare @.number2 int;
> CREATE TABLE #Table1
> (
> ValueRet int,
> )
> set @.number1=(select SUBSTRING( pol, 1 , 2 ) from table where (id IN
> (select ref from table_set where num=@.Name)));
> set @.number2=(select SUBSTRING( pol, 5 , 10 ) from table where (id IN
> (select ref from table_set where num=@.Name)));
> insert into #Table values (@.number1);
> insert into #Table values (@.number2);
> select * from #Table;
> if @.@.Error <> 0
> begin
> return @.@.error
> end
> GO
>
> The procedure runs ok within the database. I have a problem when quering
> using ODBC. I run the SQLExecDirect and it returns SUCCESS. Then I run
> the SQLBind instruction and it successes again. However when running the
> SQLFecth I get an error Invalid Cursor State (24000), while it should
> return the query values (there are values to be returned ;)) )
> Does anybody knows why that happens?
> Any help is really welcome.
>
> TA.

No comments:

Post a Comment