I am using DBI and DBD-ODBC to connect to an MSSQL Server and this query
gets an invalid cursor state:
PRINT 'starting select'
select count(*) from anytable
PRINT 'finished'
If I only run the PRINT command... it works.
If I run the full query against a sybase server... only the top select
prints.
I am using:
Win32 AS-5.8.0 Multithread build 806 DBI(1.43)DBD::ODBC(1.07) MSSQL Server I
get a invalid cursor state when I run any SQL with a PRINT statement at the
beginning of any SQL statement.
The error:
DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver]Invalid
cursor state (SQL-24000)(DB
D: dbd_describe/SQLNumResultCols err=-1) at H:\progs\dbi_test.pl line 10.
Example code:
#c:/perl/bin/perl
use DBI;
my $dbh = DBI->connect( 'dbi:ODBC:TEST_DSN', '','', {RaiseError=> 1} );
my $sql = qq#
PRINT 'starting select'
select count(*) from anytable
PRINT 'finished'
#;
my $sth = $dbh->prepare( $sql );
my $rv = $sth->execute();
while ( my $hr = $sth->fetchrow_hashref ){
print $$hr{$_}, "\n" for ( keys %$hr );
print "Err: ", $dbh->errstr, "\n" if $dbh->errstr;
}
Does this have anything to do with how SQL_SUCCESS_WITH_INFO is being
handled by the driver?
How do I get all the results..
Thanks!
James