jerryleo has asked for the wisdom of the Perl Monks concerning the following question:
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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ODBC Error - Invalid Cursor State (SQL-24000)
by Anonymous Monk on Jun 25, 2008 at 06:42 UTC | |
|
Re: ODBC Error - Invalid Cursor State (SQL-24000)
by Anonymous Monk on Jun 25, 2008 at 06:38 UTC | |
|
Re: ODBC Error - Invalid Cursor State (SQL-24000)
by roboticus (Chancellor) on Jun 27, 2008 at 13:19 UTC | |
by Anonymous Monk on Sep 03, 2010 at 22:12 UTC | |
by Anonymous Monk on Mar 18, 2011 at 19:32 UTC | |
by mje (Curate) on Mar 21, 2011 at 10:16 UTC | |
|
Re: ODBC Error - Invalid Cursor State (SQL-24000)
by mje (Curate) on Mar 21, 2011 at 10:04 UTC | |
|
Re: ODBC Error - Invalid Cursor State (SQL-24000)
by Anonymous Monk on Jun 25, 2008 at 06:48 UTC |