Re: freetds - invalid cursor state

Frediano Ziglio <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <CAHt6W4cgqxE0hF0SBdTPy8_9sDG-uudEpq8P_qjPTHP8MiL_Tg@mail.gmail.com>
2016-02-09 20:22 GMT+00:00  <[email protected]>:
>
> Hi guys, we have to find some solution.
>
> We have perl script using DBD::ODBC to connect to MSSQL using unixODBC
> driver and FreeTDS. When we execute stored procedure and this stored
> procedure is executing another stored procedure with raiserror or print
> functions we get invalid cursor state error.
>
> i.e.:
> CREATE PROCEDURE [dbo].[dummyproc] as
> RAISERROR('test', 0, 0)
> return 0
>
> CREATE PROCEDURE [dbo].[testproc] as
> select GETDATE()
> exec dummyproc
> select GETDATE()
> return 0
>
> This happens ONLY when we try to fetch results from second getdate()
> function.
> i.e.:
> my $query = 'exec testproc';
> my $sth   = $dbh->prepare($query);
> $sth->execute || die "Error running query $query";
> while ( my $d = $sth->fetchrow_arrayref ) {
>     print Dumper $d; #should return first getdate()
> }
> while ( my $d = $sth->fetchrow_arrayref ) {
>     print Dumper $d; #should return second getdate()
> }
>
> We’re using:
> Old perl 5.8.8.
> DBD::ODBC version 1.45
> unixODBC 2.3.1 (also tried newest 2.3.4.)
> FreeTDS 0.91.dev.20110409RC1 (also tried FreeTDS 0.95.81)
>
> In case we use Easysoft database driver instead of FreeTDS the error does
> not appear.
> When I call out the procedure from tsql error does not appear.
>
> The log using latest FreeTDS can be found here:
> http://jezecek.dyndns.org/freetds.log
> The unixODBC log (not sure it will help) can be found here:
> http://jezecek.dyndns.org/odbc.log
>
> I would really really appreciate if you can let me know what to focus on.
> Thank you for any hints& supprt from you.
>
> Regards,
> JJ
>

Does not look so weird. In ODBC 3 resultset can have no records, for
instance they can contains an error. You got an error in between two
recordsets with rows. It seems that DBD::ODBC calls
SQLFreeStmt(SQL_UNBIND) but this should not skip the error.
I'll check exactly in this condition what SQLNumResultCols and
SQLMoreResults returns with a Windows driver. I remember a similar
problem using an old unixODBC version.

Frediano
_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.