nelgin has asked for the wisdom of the Perl Monks concerning the following question:
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#!/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'm obviously doing something very stupid and basic and can't see it. Thanks in advance.>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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI and bind_columns issue
by Tux (Canon) on Aug 15, 2014 at 06:01 UTC | |
by nelgin (Initiate) on Aug 15, 2014 at 13:35 UTC | |
|
Re: DBI and bind_columns issue
by Anonymous Monk on Aug 15, 2014 at 01:23 UTC | |
by Tux (Canon) on Aug 15, 2014 at 06:12 UTC | |
by Anonymous Monk on Aug 15, 2014 at 07:39 UTC | |
by Anonymous Monk on Aug 15, 2014 at 03:43 UTC |