DBD::ODBC::st execute failed: unixODBCFreeTDSSQL ServerInvalid cursor state (SQL-24000) at fetch_ptu.pl line 38.
I tried following ways
1. add { RaiseError => 1, odbc_cursortype => 2} to my connection
my script halted until timeout.
2. setting of SQL_ROWSET_SIZE sql_rowset_size / odbc_SQL_ROWSET_SIZE to a value > 1
It complained
DBD::ODBC::db STORE failed: unixODBCFreeTDSSQL ServerInvalid option (SQL-HY092) at fetch_ptu.pl line 8.
And returned 1st query with complaint Invalid cursor state
56778 2008062300 8061 206 75
DBD::ODBC::st execute failed: unixODBCFreeTDSSQL ServerInvalid cursor state (SQL-24000) at fetch_ptu.pl line 38.
3. $dbh->{odbc_exec_direct} = 1
It also didn't make sense.
I did hard search on Internet, but failed to make sense.
Are there any missing? #!/usr/bin/perl use DBI ; my $dbh = DBI->connect("DBI:ODBC:$DSN",$user,$passwd) or die "Can't co +nnect to $DSN: $DBI::errstr" ; #$dbh->{odbc_sql_rowset_size} = 2; #$dbh->{odbc_SQL_ROWSET_SIZE} = 2; #$dbh->{SQL_ROWSET_SIZE} = 2; #$dbh->{sql_rowset_size} = 2; #$dbh->{odbc_exec_direct} = 1; #$dbh->{odbc_cursortype} = 2; $dbh->do("use $database"); my $sql = qq/SELECT StationNum, ObservTimes, StationPress, DryBulTemp, + RelHumidity FROM tabTimeData /; $sql .= qq/ WHERE StationNum= ? /; $sql .= qq/ AND ( ObservTimes >= ? AND ObservTimes <= ?) / ; $sql .= qq/ ORDER BY ObservTimes ASC/ ; my $sth1 = $dbh->prepare($sql) or die "Can't prepare statement: $DBI:: +errstr"; $sql = qq/SELECT StationNum, ObservTimes, StationPress, DryBulTemp, Re +lHumidity FROM tabRealTimeData /; $sql .= qq/ WHERE StationNum= ? /; $sql .= qq/ AND ( ObservTimes >= ? AND ObservTimes <= ?) / ; $sql .= qq/ ORDER BY ObservTimes ASC/ ; my $sth2 = $dbh->prepare($sql) or die "Can't prepare statement: $DBI:: +errstr"; $sth1->execute(($SN,$sEPOCH,$eEPOCH)) ; while ( my @row00 = $sth1->fetchrow_array ) { my ($STID,$EPOCH,$P,$T,$U) = @row00; print "$STID\t$EPOCH\t$P\t$T\t$U\n"; $sth2->execute(($SN,${sEPOCH}.'00',${eEPOCH}.'59')) ; while ( my @rownn = $sth2->fetchrow_array ) { ($STID,$EPOCH,$P,$T,$U) = @rownn; print "$STID\t$EPOCH\t$P\t$T\t$U\n"; } $sth2->finish; } $sth1->finish; $dbh->disconnect if ($dbh) ; exit(0);
In reply to ODBC Error - Invalid Cursor State (SQL-24000) by jerryleo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |