At the very least this is a bug in freeTDS since the error message is wrong. IF there were more rows to fetch on the first statement handle then the error should be something like cannot use multiple active statements. Also the erroneous invalid cursor state is on the execute of the second statement which also makes no sense.

DBD::ODBC will close the cursor when finish is called or when a fetch returns SQL_NO_DATA or when the statement handle goes out of scope. Your example does not fetch after the first row so it does not know to call SQLCloseCursor, you do not call finish and the statement handle does not go out of scope.

The SQL Server ODBC driver knows the result-set is finished, presumably, because it received a TDS done packet.

Other than freeTDS I do not know of any ODBC driver which would not work with your example.


In reply to Re: FreeTDS (Linux) vs. SQLSRV32.dll (Windows) via ODBC by mje
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.