• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1212
  • Last Modified:

Perl fetch error from remote Dell KACE1000

Oh mighty Perl Master Wizards !
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=''
      my $username= 'R1'; #same for every customer
      my $password= 'box747'; #same for every customer
      my $dbh = DBI->connect("dbi:ODBC:DRIVER=$database;SERVER=$hostname;port=3306",$username$password)";

Open in new window


## herein lies error screen return on exec()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);
      ## 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";

Open in new window

## any help is very much appreciated
JAaron Anderson
JAaron Anderson
  • 5
  • 3
4 Solutions
First, you should add the strict and warnings pragmas and remove the -w switch.
use strict;
use warnings;

Open in new window

Second, I'd use DBD::mysql instead of ODBC.

The error you're receiving is due to your select statement.  If you only want 4 fields (not all 74), then specify those exact fields rather than selecting all fields.
JAaron AndersonProgramming Architect @ Widener UniversityAuthor Commented:
>> use strict;
>> use warnings;
yes Ive tried them ... each scenario in fact w/ & w/o no difference Ill keep em in ..
more stongly typed that way thx...

I was told to use ODBC do you have documentation that is for KACE which states otherwise ? I followed their "best practices" here :
and more directly here:

if you suggest DBD::mysql what is its latest installer which works with ActiveState's binary build 1402 of Perl 5 v14 sub2 for MSWin32-x64...
I don't have any experience with KACE, but if it is using mysql, then the standard/default perl driver would be DBD::mysql.  It is in Activestate's repository and could be easily installed via:
ppm install DBD::mysql

Actually, as I was writing this I noticed that you're using 64bit perl.  I'm not sure if the 64bit version is in the repository.  If it isn't and you don't want to deal with it, you could stay with the ODBC driver.  It's not that big of a deal.

The key issue you need to fix is the select statement.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

JAaron AndersonProgramming Architect @ Widener UniversityAuthor Commented:
suite !
found it here http://code.activestate.com/ppm/DBD-mysql/ 
making an ISO now to install it on isolated DMZ test server
JAaron AndersonProgramming Architect @ Widener UniversityAuthor Commented:
of course ...
Authorization Required to download 4.021 build for my ActiveState Perl 5.14 build 64bit

.. stay tuned on that; i have an email out to my sales contact 'Fred' lol ...

but for now is there anything we can think to work on the fetch statement for my query irregardless of what driver Im using ? just curious thx

Open in new window

my $sql = 'SELECT id, name, user, mac FROM ORG1.MACHINE';

Open in new window

Adjust those field names to match what you have in your database.
JAaron AndersonProgramming Architect @ Widener UniversityAuthor Commented:
lol of course that worked completely without a hitch lol
JAaron AndersonProgramming Architect @ Widener UniversityAuthor Commented:
@FishMonger is the quickest replies Ive EVER had and he rocked it !

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now