jaaronanderson has asked for the wisdom of the Perl Monks concerning the following question:

Oh mighty Perl Monks!                                          §           I beseech your wisdom in my troubled past. For you see I have ventured on a noble quest but am lost on my journey. lol                  (I feel this is an excerpt out of the movie "Your Highness" http://www.imdb.com/title/tt1240982/ lol)                 anyhow ...                     I am successfully BINDing to my remote Dell KACE1000 with this snippet :
#!/usr/perl -w use DBI; my $database='MySQL ODBC 3.51 Driver'; my $hostname='192.168.1.100' my $username= 'R1'; #same for every customer my $password= 'box747'; #same for every customer my $dbh = DBI->connect("dbi:ODBC:DRIVER=$database;SERVER=$hostna +me;port=3306",$username$password)";
## heres my syntax confusion; Ive tried many statement approaches ## NONE of which seem to work valid ## this block gives me error confirming record/value traversal ## it is not returning anything; giving me this DBI::errstr error(s) ## bind_columns failed: called with 4 values but 74 are needed
my $sql = "SELECT * FROM ORG1.MACHINE"; ## SQL works in MySQL studio where ORG1:db and MACHINE:table my $sth = $dbh->prepare($sql); $sth->execute(); ## should I be sure to inject (undef) my ($ID, $NAME, $USER, $MAC); ## Titles correspond to Schema Viewer table names in CAPS #BIND results to variables ? $sth->bind_columns(undef, \$ID, \$NAME, \$USER, \$MAC); ##retrieve / return results while( $sth->fetch() ) { print "$ID, $NAME, $USER, $MAC\n"; } $sth->finish(); $dbh->disconnect();
## any help is very much appreciated                     ##Below is a screenshot of the returned error on execution                                 http://filedb.experts-exchange.com/incoming/2012/08_w33/t596770/ODBCfailederror.png

Replies are listed 'Best First'.
Re: Dell KACE lookup script failure
by aitap (Curate) on Aug 16, 2012 at 15:25 UTC
    ## bind_columns failed: called with 4 values but 74 are needed
    my $sql = "SELECT * FROM ORG1.MACHINE";
    $sth->bind_columns(undef, \$ID, \$NAME, \$USER, \$MAC);
    Perhaps you really have 74 columns in that table, not just 4? Try SELECTing only ID, NAME, USER, MAC instead if *.
    Sorry if my advice was wrong.