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='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=$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);
      $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();

Open in new window



## any help is very much appreciated
JAaron AndersonProgramming Architect @ Widener UniversityAsked:
Who is Participating?
 
FishMongerCommented:
Change:
my $sql = "SELECT * FROM ORG1.MACHINE";

Open in new window

To:
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.
0
 
FishMongerCommented:
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.
0
 
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...

>>DBD::mysql
I was told to use ODBC do you have documentation that is for KACE which states otherwise ? I followed their "best practices" here :
http://www.kace.com/uk/support/resources/kb/article/How-to-connect-to-the-K1000-appliance-database-using
and more directly here:
http://www.kace.com/uk/support/resources/kb/article/Can-I-access-the-K1000-appliance-database-using

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...
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
FishMongerCommented:
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.
0
 
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
0
 
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
0
 
JAaron AndersonProgramming Architect @ Widener UniversityAuthor Commented:
lol of course that worked completely without a hitch lol
thx
0
 
JAaron AndersonProgramming Architect @ Widener UniversityAuthor Commented:
@FishMonger is the quickest replies Ive EVER had and he rocked it !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.