I haven't worked with it for a few years, but I did a lot of stuff that used FreeTDS to talk to SQL Server a while back, and I was never able to get it to work with multiple active statements on a single connection. I would always end up with the same "Invalid cursor state" error you're seeing.

We researched the issue pretty extensively and were unable to find a workaround, FreeTDS was missing support for the cursor types needed to make this possible. I'm guessing that this is still the case. As others have said, you'll either need to keep calling fetchrow_whatever until it returns undef or use the finish method to wrap up the current statement before you fire off another. That, or you could always open up a second connection.

Also, watch out for NULL (\0) characters at the end of strings returned from your queries. We started seeing that come out of DBI::ODBC + FreeTDS when we moved up to SQL Server 2005.


In reply to Re: FreeTDS (Linux) vs. SQLSRV32.dll (Windows) via ODBC by coldguy
in thread FreeTDS (Linux) vs. SQLSRV32.dll (Windows) via ODBC by pvbcharon

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.