I'm running the code below and not having much luck getting the bound variables to return any data. I can't see what I'm doing wrong so I need a second (or more) pair of eyes to give me some help please. I know data is being returned, because I get 166 blank lines returned!
#!/usr/bin/perl use strict; use DBI; my $level=3; my $district="50"; my $dbh = DBI->connect('dbi:mysql:database=db','un', 'pw') || die $DBI +::errstr; my $distquery = "SELECT tm_club_district, tm_club_number FROM clubs W +HERE tm_club_district=?"; my %row; # if omitted Global symbol "%row" requires explicit package n +ame my $row; # if omitted Global symbol "$row" requires explicit package n +ame my $sqlquery = $dbh->prepare($distquery); $sqlquery->execute($district); $sqlquery->bind_columns( \( @row{ @{$sqlquery->{NAME_lc} } } )); print "START\n"; while ($sqlquery->fetch) { print $row->{tm_club_number} . " - " . $row->{tm_club_district} ."\n +"; } print "EMD\n";
I followed the example in perldoc DBI but seem to be getting nowhere. The script checks out and works fine, however I'm getting no data from the backend database into the bound variables. $ perl -cw ww.pl ww.pl syntax OK In the dbi log I can see the bind variables
>parse_params statement SELECT tm_club_district, tm_club_number FROM c +lubs WHERE tm_club_district=? Binding parameters: SELECT tm_club_district, tm_club_number FROM clubs + WHERE tm_club_district='50' <- dbd_st_execute returning imp_sth->row_num 166 <- execute= 166 at ww.pl line 16 -> FETCH for DBD::mysql::st (DBI::st=HASH(0xN)~INNER 'NAME_lc') th +rN -> dbd_st_FETCH_attrib for 02701b10, key NAME_lc -> dbd_st_FETCH_attrib for 02701b10, key NAME <- FETCH= [ 'tm_club_district' 'tm_club_number' ] at ww.pl line 18
I'm obviously doing something very stupid and basic and can't see it. Thanks in advance.

In reply to DBI and bind_columns issue by nelgin

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.