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

Can someone please look into my below code and error and suggest what exactly is the error here and How should I move forward to get it right. Thanks in advance.
#!/u001/dev/edw/common/ul/bin/perl #Batch history: Developed by Saurav Rout use strict; use warnings; use DBI; use DBD::ODBC; my $host = "db.myhost.com"; # = "localhost", the server your are on. my $db = "u210502"; # your username (= login name = account nam +e ) my $user = $db; # your Database name is the same as your acc my $pwd = 'xxxxxx'; # Your account password # connect to the database. print(__PACKAGE__ . ':' . __LINE__ . ":Connecting...\n"); $dbh = DBI->connect( "DBI:ODBC:$host", $user, $pwd) or die "Connecting : $DBI::errstr\n "; print(__PACKAGE__ . ':' . __LINE__ . ":Connected.\n"); $sql = "SELECT * FROM D_EIW_W_DEVWORK_1.daily_batch_report"; # executing the SQL statement. $sth = $dbh->prepare($sql) or die "preparing: ",$dbh->errstr; $sth->execute or die "executing: ", $dbh->errstr; print "content-type: text/html\n\n"; # one of the functions to retrieve data from the table results # check perldoc DBI for more methods. while ($row = $sth->fetchrow_hashref) { foreach(sort(keys(%$row))) { print("$_:\[$row->{$_}\]\n"); } }
And the error I am getting is:
[edwdev2:u210502] /u001/dev/edw/common/ul/cgi-bin/eiw $ perl batch_his +t Can't load '/u001/dev/edw/common/ul/perl5/lib/site_perl/5.8.0/aix-64al +l/auto/DBD/ODBC/ODBC.so' for module DBD::ODBC: 0509-022 Cannot loa +d module /u001/dev/edw/common/ul/perl5/lib/site_perl/5.8.0/aix-64all/ +auto/DBD/ODBC/ODBC.so. 0509-150 Dependent module libodbc.a(odbc.so) could not be lo +aded. 0509-022 Cannot load module libodbc.a(odbc.so). 0509-026 System error: A file or directory in the path name do +es not exist. 0509-022 Cannot load module /u001/dev/edw/common/ul/perl5/lib/ +site_perl/5.8.0/aix-64all/auto/DBD/ODBC/ODBC.so. 0509-150 Dependent module /u001/dev/edw/common/ul/perl5/lib/ +site_perl/5.8.0/aix-64all/auto/DBD/ODBC/ODBC.so could not be loaded. +at /u001/dev/edw/common/ul/perl5/lib/5.8.0/aix-64all/DynaLoader.pm li +ne 229. at batch_hist line 8 Compilation failed in require at batch_hist line 8. BEGIN failed--compilation aborted at batch_hist line 8.

Replies are listed 'Best First'.
Re: Perl ODBC error
by marto (Cardinal) on Oct 27, 2013 at 09:26 UTC

    How did you install DBD::ODBC? Did you install the unixODBC/unixODBC-dev packages for your system/architecture? I suggest you read and understand DBD::ODBC::FAQ where it discusses prerequisites and platform specifics. As a side note, you posted in the wrong section of the forum, your question has been moved. Please read PerlMonks for the Absolute Beginner.

      Yes. I have the module installed.
      [edwdev2:u210502] /u001/dev/edw/common/ul/perl5/lib/site_perl/5.8.0/ai +x-64all/auto/DBD $ ls -lrt total 0 drwxrwxr-x 3 edw01 edwprocs 256 Jul 09 2007 DB2 drwxrwxr-x 2 edw01 edwprocs 256 Sep 04 2008 ODBC drwxr-xr-x 2 edw01 edwprocs 256 Jul 23 2012 SQLite [edwdev2:u210502] /u001/dev/edw/common/ul/perl5/lib/site_perl/5.8.0/ai +x-64all/auto/DBD $ cd ODBC;ls -lrt total 328 -r--r--r-- 1 edw01 edwprocs 0 May 04 2007 ODBC.bs -r-xr-xr-x 1 edw01 edwprocs 164149 Sep 04 2008 ODBC.so

        That is not what marto was pointing you at. Have you installed unixODBC? unixOBDC is the ODBC driver manager and it is an opensource project. Also, how did you install DBD::ODBC? Let us see the output of when you ran "perl Makefile.PL for DBD::ODBC.

        Original parent post content:

        Yes. I have the module installed.
        [edwdev2:u210502] /u001/dev/edw/common/ul/perl5/lib/site_perl/5.8.0/ai +x-64all/auto/DBD $ ls -lrt total 0 drwxrwxr-x 3 edw01 edwprocs 256 Jul 09 2007 DB2 drwxrwxr-x 2 edw01 edwprocs 256 Sep 04 2008 ODBC drwxr-xr-x 2 edw01 edwprocs 256 Jul 23 2012 SQLite [edwdev2:u210502] /u001/dev/edw/common/ul/perl5/lib/site_perl/5.8.0/ai +x-64all/auto/DBD $ cd ODBC;ls -lrt total 328 -r--r--r-- 1 edw01 edwprocs 0 May 04 2007 ODBC.bs -r-xr-xr-x 1 edw01 edwprocs 164149 Sep 04 2008 ODBC.so
Re: Perl ODBC error
by runrig (Abbot) on Oct 28, 2013 at 21:14 UTC

    Original parent post content:

    Can someone please look into my below code and error and suggest what exactly is the error here and How should I move forward to get it right. Thanks in advance.
    #!/u001/dev/edw/common/ul/bin/perl #Batch history: Developed by Saurav Rout use strict; use warnings; use DBI; use DBD::ODBC; my $host = "db.myhost.com"; # = "localhost", the server your are on. my $db = "u210502"; # your username (= login name = account nam +e ) my $user = $db; # your Database name is the same as your acc my $pwd = 'xxxxxx'; # Your account password # connect to the database. + print(__PACKAGE__ . ':' . __LINE__ . ":Connecting...\n"); $dbh = DBI->connect( "DBI:ODBC:$host", $user, $pwd) or die "Connecting + : $DBI::errstr\n "; print(__PACKAGE__ . ':' . __LINE__ . ":Connected.\n"); $sql = "SELECT * FROM D_EIW_W_DEVWORK_1.daily_batch_report"; # executi +ng the SQL statement. $sth = $dbh->prepare($sql) or die "preparing: ",$dbh->errstr; $sth->execute or die "executing: ", $dbh->errstr; print "content-type: text/html\n\n"; # one of the functions to retriev +e data from the table results # check perldoc DBI for more methods. while ($row = $sth->fetchrow_hashref) { foreach(sort(keys(%$row))) { print("$_:\[$row->{$_}\]\n"); } }
    And the error I am getting is:
    [edwdev2:u210502] /u001/dev/edw/common/ul/cgi-bin/eiw $ perl batch_his + +t Can't load '/u001/dev/edw/common/ul/perl5/lib/site_perl/5.8.0/aix +-64al +l/auto/DBD/ODBC/ODBC.so' for module DBD::ODBC: 0509-022 Cannot + loa +d module /u001/dev/edw/common/ul/perl5/lib/site_perl/5.8.0/aix- +64all/ +auto/DBD/ODBC/ODBC.so. 0509-150 Dependent module libodbc.a(od +bc.so) could not be lo +aded. 0509-022 Cannot load module libodbc.a(o +dbc.so). 0509-026 System error: A file or directory in the path name +do +es not exist. 0509-022 Cannot load module /u001/dev/edw/common/ul +/perl5/lib/ +site_perl/5.8.0/aix-64all/auto/DBD/ODBC/ODBC.so. 0509-15 +0 Dependent module /u001/dev/edw/common/ul/perl5/lib/ +site_perl/5.8. +0/aix-64all/auto/DBD/ODBC/ODBC.so could not be loaded. +at /u001/dev/ +edw/common/ul/perl5/lib/5.8.0/aix-64all/DynaLoader.pm li +ne 229. at +batch_hist line 8 Compilation failed in require at batch_hist line 8. + BEGIN failed--compilation aborted at batch_hist line 8.