Perl fetch error from remote Dell KACE1000

Posted on 2012-08-16
Last Modified: 2012-08-21
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" 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
Question by:jandersonwidener
    LVL 28

    Assisted Solution

    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.

    Author Comment

    >> 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...
    LVL 28

    Assisted Solution

    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.

    Assisted Solution

    suite !
    found it here
    making an ISO now to install it on isolated DMZ test server

    Author Comment

    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
    LVL 28

    Accepted Solution

    my $sql = "SELECT * FROM ORG1.MACHINE";

    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.

    Author Comment

    lol of course that worked completely without a hitch lol

    Author Closing Comment

    @FishMonger is the quickest replies Ive EVER had and he rocked it !

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Invalid Identifier Error 3 49
    What does this SQL mean? 7 33
    SQL Update Query 23 66
    Case statement to sum values - T-SQL 3 30
    Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
    This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now