Fellow monks
I have the following snippet running on Win32, against a MSSQL2000 server:
my $sql =<<'EOFSQL'; SELECT LOWER(field_one), field_two, UPPER(field_three) FROM sample_table (NOLOCK) WHERE field_one = ? EOFSQL my $sth = $dbh->prepare($sql) or die; my ($field_one, $field_two, $field_three); for my $test_value (@test_values) { $sth->bind_param(1, $test_value); $sth->execute; $sth->bind_columns(\$field_one, \$field_two, \$field_three); while ($sth->fetch) { print join "-", ($field_one, $field_two, $field_three); } }
When this runs, $field_one gets clobbered by the contents of $field_three, as if $sth->fetchwere returning a hash,
but it's documented as being an alias of $sth->fetchrow_arrayref
Doing a print join "<->", @{$sth->{NAME}}; gives <->field_two<->, "confirming" my idea.
I have changed my query to explicitly name the columns, but am curious to understand what's going on.

Update:
gmax has spotted where the problem is.
The behaviour I see is using DBD::ADO with a sqloledb Provider
When using DBD::ODBC, "unnamed" colums retain their values and do not step over each other.
Now I wonder where I should file a bug report... :)
Update 2:
As per DBD:ADO maintainer, this is a bug in versions <2.87. I was using 2.84, and after an update to version 2.91, my "unnamed" columns work correctly.

--
Olivier

In reply to DBD: bind_column behviour with multiple "unnamed" columns by olivierp

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.