Hi monks,

I need to get the result message of the query coded below to parse.

my $dbcon = DBI->connect ( qq{dbi:ODBC:driver={SQL Server};Server=127.0.0.1;database=master;}, qq{sa}, qq{*********} ) or die qq{Can't connect to database, erro : $DBI::errstr}; my $sth = $dbcon->prepare(q{ use [Northwind] DECLARE @id int, @indid int, @counter dec (15) CREATE TABLE #Temp ( id int, indid int ) INSERT INTO #Temp SELECT o.id, i.indid FROM sysobjects AS o FULL JOIN sysindexes AS i ON o.id = i.id WHERE o.xtype = 'U' SELECT @counter = COUNT(*) FROM #Temp SET rowcount 1 WHILE ( @counter ) > 0 BEGIN SELECT @id = id, @indid = indid FROM #Temp SET @counter = @counter -1 DBCC SHOWCONTIG (@id, @indid) DELETE FROM #Temp WHERE id = @id and indid = @indid END SET rowcount 0 DROP TABLE #Temp}) || die "Can't prepare sql:\n$DBI::errstr\n"; $sth->execute(); print $DBI::errstr;
But even the SQL code running well on SQL Query Analyzer, I'm getting the error message DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver]Invalid cursor state (SQL-24000)(DBD: dbd_describe/SQLNumResultCols err=-1).

I'd like your help on 2 way, first to help-me on this error message, and second in how can I get the result message of the query.

Thanks,

Solli Moreira Honorio
Sao Paulo - Brazil

In reply to Getting MSSQL message return on DBI by shonorio

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.