Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Please can someone explain the following error:
DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver]Inval +id cursor state (SQL-24000)(DBD: dbd_describe/SQLNumResultCols err=-1) at Rerun_ +check_C.pl line 1005. Couldn't execute query: [Microsoft][ODBC SQL Server Driver]Invalid cur +sor state (SQL-24000)(DBD: dbd_describe/SQLNumResultCols err=-1) at Rerun_check_ +C.pl line 1005.
In the context of the following code:
") or die "Couldn't prepare query: ".$dbh->errstr; $create_table_B->execute() or die "Couldn't execute query: ".$cr +eate_table_B->errstr;

Replies are listed 'Best First'.
Re: DBD: dbd_describe/SQLNumResultCols err=-1
by gellyfish (Monsignor) on Jul 05, 2004 at 15:11 UTC

    NO not really - I think you will probably have to show us the code that connects to the database and prepares the queries.

    However the SQL Server documentation says:

    you may receive the "Invalid cursor state" error message when Microsoft® SQL Server™ runs out of resources while attempting to save selected tables or a database diagram. This error is returned because of insufficient space in your database or transaction log to complete the save process. To correct this problem, check to see if the database or the transaction log is full. If so, increase the size of the database to accommodate the change. Check other system resources or contact your system administrator.

    /J\

Re: DBD: dbd_describe/SQLNumResultCols err=-1
by mpeppler (Vicar) on Jul 05, 2004 at 15:47 UTC
    In addition to gellyfish's comments - it looks like you have more than one active $sth on the same connection, and this may be the cause of the problem. SQL Server (and Sybase) in general don't support multiple active statements on the same connection.

    Michael

Re: DBD: dbd_describe/SQLNumResultCols err=-1
by VSarkiss (Monsignor) on Jul 05, 2004 at 23:13 UTC

    I'm going to go out on a limb here, and guess (based on your variable name) that you're trying to prepare a create table statement. In general, you don't want to do that: a simple $dbh->do() will do the trick, since you don't need to bind anything or get a result set back.

    If you aren't trying to create a table, please show the actual SQL you're trying to prepare.