I seem to have an ODBC problem. My query works fine when I run it using the Microsoft SQL 2000 Query Analyzer. But when I run the same EXEC query through a Perl Program the stored procedure that is activated by the EXEC statement stalls half way through the process. I have tried to fiddle with the permission setting of the table that I think is read at the time of the stall, but with no success. The error message I get is:
U:\2004_2005\Development\Perl_development\20_October_2004>perl 20_Octo +ber_2004_E.pl DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver]Inval +id cursor state (SQL-24000)(DBD: dbd_describe/SQLNumResultCols err=-1) at 20_Oct +ober_2004_E.pl line 290. Couldn't execute query: [Microsoft][ODBC SQL Server Driver]Invalid cur +sor state (SQL-24000)(DBD: dbd_describe/SQLNumResultCols err=-1) at 20_October_2 +004_E.pl line 290.
The important bits of Perl code for this are:
#! perl -w scipt use strict; use warnings; use DBI; use DBD::ODBC; my ($data_source, $database, $user_id, $password) = qw( <ip address> S +eries_requests ********* ********* ); my $conn_string = "driver={SQL Server}; Server=$data_source; Database= +$database; Trusted_Connection=yes"; my $dbh = DBI->connect( "DBI:ODBC:$conn_string" ) or die $DBI::errstr;
Then, after the query is defined.
my $sthB_A = $dbh->prepare("$Query_A") or die "Couldn't prepare que +ry: ".$dbh->errstr; $sthB_A->execute() or die "Couldn't execute query: ".$sthB_A->errstr +;

In reply to ODBC problem by Win

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.