Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default need DBD::ODBC help

    I'm trying to get a Linux box, with RedHat 8 and Perl 5.8.0, to connect with an
    AS400 machine through ODBC. I'm fairly sure I can get it to connect, because I
    don't get an error until I try to use $db->prepare(). I will post the code and
    errors below. I get two errors, but I am fairly sure the second error is a
    result of the first. My main questions, to anyone who has written a Perl
    script/program that connects to an IBM machine, are three-fold:

    1. What am I doing wrong?

    2. Should I be using DBD::DB2?

    3. If so, what kind of drivers do I need to use DBD::DB2?

    Thanks for any help, as me and my boss have spent a good bit of time digging
    through IBM sites, the Usenet, and the web. Thanks. Here's the bit of code
    I'm using to "prototype" a connection:

    Code:
    #!/usr/bin/perl -w
    
    use strict;
    use DBI;
    
    my $db = DBI->connect('dbi:ODBC:AS400', 'myid', 'mypassword')  or die
    $DBI::errstr;
    
    my $out = $db->prepare("SELECT * FROM CD02 WHERE CD02_INSTRNO = '4110'");
    $out->execute() or die $DBI::errstr;
    
    while (my @lala = $out->fetchrow_array()) {
    foreach my $la (@lala) {
    print "$la\t";
    }
    
    print "\n";
    }
    
    exit;
    ....and here are the errors I get:

    [errors]
    DBD::ODBC::db prepare failed: [unixODBC][IBM][iSeries Access ODBC Driver][DB2
    UDB] (SQL-HY000)
    [unixODBC][IBM][iSeries Access ODBC Driver][DB2 UDB] (SQL-42S02)(DBD:
    st_prepare/SQLPrepare err=-1) at ./odbctest line 8.
    Can't call method "execute" on an undefined value at ./odbctest line 9.
    [/errors]


    Andrew Burton - tuglyraisin at aol dot com
    Felecia Station on Harvestgain - [url]http://www.darkbeast.com/[/url]
    "I often question my sanity; it has yet to give me a straight answer."
    "And if you're bored, it's because... you're boring." - Matt Drudge
    Andrew Burton Guest

  2. Similar Questions and Discussions

    1. ODBC driver does not show up in driver list in ODBC data source administrator
      Installed an ODBC driver on a Windows Server 2003 machine. A key shows up in the registry under HKEY_LOCAL_MACHINE- seperate listing under...
    2. ODBC Socket doesn't show my list of ODBC DSN's!?!
      In the ColdFusion MX 7 Administrator, when I try to create a new datasource of type ?ODBC Socket?, the drop down labled ?ODBC DSN? that is supposed...
    3. [ODBC] ODBC (win32) X PostgreSQL(Linux)
      Hi Fabricio, fbbsantos wrote: I need to know enough that if I sat down at your computer I could find the problem. For example, what...
    4. #24697 [Fbk->NoF]: odbc can not return accurate result when we handle excel file use odbc
      ID: 24697 Updated by: sniper@php.net Reported By: tty3000 at hotmail dot com -Status: Feedback +Status: ...
    5. #24697 [NEW]: odbc can not return accurate result when we handle excel file use odbc
      From: tty3000 at hotmail dot com Operating system: win 2000 PHP version: 4.3.2 PHP Bug Type: ODBC related Bug description: ...
  3. #2

    Default need DBD::ODBC help

    [cross-posted from comp.lang.perl.misc since this is a DB2 question.]

    I'm trying to get a Linux box, with RedHat 8 and Perl 5.8.0, to connect with an
    AS400 machine through ODBC. I'm fairly sure I can get it to connect, because I
    don't get an error until I try to use $db->prepare(). I will post the code and
    errors below. I get two errors, but I am fairly sure the second error is a
    result of the first. My main questions, to anyone who has written a Perl
    script/program that connects to an IBM machine, are three-fold:

    1. What am I doing wrong?

    2. Should I be using DBD::DB2?

    3. If so, what kind of drivers do I need to use DBD::DB2?

    Thanks for any help, as me and my boss have spent a good bit of time digging
    through IBM sites, the Usenet, and the web. Thanks. Here's the bit of code
    I'm using to "prototype" a connection:

    Code:
    #!/usr/bin/perl -w
    
    use strict;
    use DBI;
    
    my $db = DBI->connect('dbi:ODBC:AS400', 'myid', 'mypassword')  or die
    $DBI::errstr;
    
    my $out = $db->prepare("SELECT * FROM CD02 WHERE CD02_INSTRNO = '4110'");
    $out->execute() or die $DBI::errstr;
    
    while (my @lala = $out->fetchrow_array()) {
    foreach my $la (@lala) {
    print "$la\t";
    }
    
    print "\n";
    }
    
    exit;
    ....and here are the errors I get:

    [errors]
    DBD::ODBC::db prepare failed: [unixODBC][IBM][iSeries Access ODBC Driver][DB2
    UDB] (SQL-HY000)
    [unixODBC][IBM][iSeries Access ODBC Driver][DB2 UDB] (SQL-42S02)(DBD:
    st_prepare/SQLPrepare err=-1) at ./odbctest line 8.
    Can't call method "execute" on an undefined value at ./odbctest line 9.
    [/errors]

    Andrew Burton - tuglyraisin at aol dot com
    Felecia Station on Harvestgain - [url]http://www.darkbeast.com/[/url]
    "I often question my sanity; it has yet to give me a straight answer."
    "And if you're bored, it's because... you're boring." - Matt Drudge
    Andrew Burton Guest

  4. #3

    Default Re: need DBD::ODBC help

    see below ...

    Andrew Burton wrote:
    > I'm trying to get a Linux box, with RedHat 8 and Perl 5.8.0, to connect with an
    > AS400 machine through ODBC. I'm fairly sure I can get it to connect, because I
    > don't get an error until I try to use $db->prepare(). I will post the code and
    > errors below. I get two errors, but I am fairly sure the second error is a
    > result of the first. My main questions, to anyone who has written a Perl
    > script/program that connects to an IBM machine, are three-fold:
    >
    > 1. What am I doing wrong?
    >
    > 2. Should I be using DBD::DB2?
    I would. ODBC will most likely not be as fast as the native driver for DB2.
    >
    > 3. If so, what kind of drivers do I need to use DBD::DB2?
    I would guess you will need to install DB2 on your linux server.
    >
    > Thanks for any help, as me and my boss have spent a good bit of time digging
    > through IBM sites, the Usenet, and the web. Thanks. Here's the bit of code
    > I'm using to "prototype" a connection:
    >
    >
    Code:
    > #!/usr/bin/perl -w
    >
    > use strict;
    > use DBI;
    >
    > my $db = DBI->connect('dbi:ODBC:AS400', 'myid', 'mypassword')  or die
    > $DBI::errstr;
    >
    > my $out = $db->prepare("SELECT * FROM CD02 WHERE CD02_INSTRNO = '4110'");
    Code:
    Your error message is too vague.  Check for success:
    
    $db->prepare("...") || die $DBI::errstr;
    
    > $out->execute() or die $DBI::errstr; > > while (my @lala = $out->fetchrow_array()) { > foreach my $la (@lala) { > print "$la\t"; > } > > print "\n"; > } > > exit; >
    >
    > ...and here are the errors I get:
    >
    > [errors]
    > DBD::ODBC::db prepare failed: [unixODBC][IBM][iSeries Access ODBC Driver][DB2
    > UDB] (SQL-HY000)
    > [unixODBC][IBM][iSeries Access ODBC Driver][DB2 UDB] (SQL-42S02)(DBD:
    > st_prepare/SQLPrepare err=-1) at ./odbctest line 8.
    What is "SQL-42S02"?
    > Can't call method "execute" on an undefined value at ./odbctest line 9.
    > [/errors]
    >
    >
    > Andrew Burton - tuglyraisin at aol dot com
    > Felecia Station on Harvestgain - [url]http://www.darkbeast.com/[/url]
    > "I often question my sanity; it has yet to give me a straight answer."
    > "And if you're bored, it's because... you're boring." - Matt Drudge

    --
    Ron Reidy
    Oracle DBA

    Ron Reidy Guest

  5. #4

    Default Re: need DBD::ODBC help

    [email]tuglyraisin@aol.comm[/email]cast (Andrew Burton) writes:
    > use strict;
    > use DBI;
    >
    > my $db = DBI->connect('dbi:ODBC:AS400', 'myid', 'mypassword') or die
    > $DBI::errstr;
    >
    > my $out = $db->prepare("SELECT * FROM CD02 WHERE CD02_INSTRNO = '4110'");
    > $out->execute() or die $DBI::errstr;
    [snip]
    > ...and here are the errors I get:
    >
    > [errors]
    > DBD::ODBC::db prepare failed: [unixODBC][IBM][iSeries Access ODBC Driver][DB2
    > UDB] (SQL-HY000)
    > [unixODBC][IBM][iSeries Access ODBC Driver][DB2 UDB] (SQL-42S02)(DBD:
    > st_prepare/SQLPrepare err=-1) at ./odbctest line 8.
    > Can't call method "execute" on an undefined value at ./odbctest line 9.
    > [/errors]
    Well, the prepare is failing for some strange reason. Can you execute this
    as a simple `do' query, ie

    | $rv = $db->do($statement);

    ?

    Also, what about trying to execute the same statement against the same DSN
    using either unixODBC's `isql' tool, or iODBC's `iodbctest'? Any errors
    there?

    ~Tim
    --
    Product Development Consultant
    OpenLink Software
    Tel: +44 (0) 20 8681 7701
    Web: <http://www.openlinksw.com>
    Universal Data Access & Data Integration Technology Providers
    Tim Haynes Guest

  6. #5

    Default Re: need DBD::ODBC help


    "Andrew Burton" <tuglyraisin@aol.commcast> wrote in
    news:20030915124946.03231.00000839@mb-m11.aol.com...
    > I'm trying to get a Linux box, with RedHat 8 and Perl 5.8.0, to
    connect with an
    > AS400 machine through ODBC. I'm fairly sure I can get it to
    connect, because I
    > don't get an error until I try to use $db->prepare(). I will
    post the code and
    > errors below. I get two errors, but I am fairly sure the second
    error is a
    > result of the first.
    Yep.
    > My main questions, to anyone who has written a Perl
    > script/program that connects to an IBM machine, are three-fold:
    >
    > 1. What am I doing wrong?
    >
    > 2. Should I be using DBD::DB2?
    >
    > 3. If so, what kind of drivers do I need to use DBD::DB2?
    >
    > Thanks for any help, as me and my boss have spent a good bit of
    time digging
    > through IBM sites, the Usenet, and the web. Thanks. Here's the
    bit of code
    > I'm using to "prototype" a connection:
    >
    > [code]
    > #!/usr/bin/perl -w
    >
    > use strict;
    > use DBI;
    >
    > my $db = DBI->connect('dbi:ODBC:AS400', 'myid', 'mypassword')
    or die
    > $DBI::errstr;
    # write a tracefile, perhaps you'll get a better error message.
    # raise the tracelevel for more info (--> perldoc DBI)
    $db->trace(3, 'trace.log');
    > my $out = $db->prepare("SELECT * FROM CD02 WHERE CD02_INSTRNO =
    '4110'");
    > $out->execute() or die $DBI::errstr;
    $out will be undefined when the prepare fails. You should check
    that.

    [snipped the rest]

    Thomas


    Thomas Kratz Guest

  7. #6

    Default Re: need DBD::ODBC help

    Andrew,

    If you have a DB2 Connect box, then you can use this to connect up to DB2
    from a standard DB2 client.

    Then you can use DBD::DB2.

    Phil


    On Mon, 15 Sep 2003 17:03:23 +0000, Andrew Burton wrote:
    > [cross-posted from comp.lang.perl.misc since this is a DB2 question.]
    >
    > I'm trying to get a Linux box, with RedHat 8 and Perl 5.8.0, to connect with an
    > AS400 machine through ODBC. I'm fairly sure I can get it to connect, because I
    > don't get an error until I try to use $db->prepare(). I will post the code and
    > errors below. I get two errors, but I am fairly sure the second error is a
    > result of the first. My main questions, to anyone who has written a Perl
    > script/program that connects to an IBM machine, are three-fold:
    >
    > 1. What am I doing wrong?
    >
    > 2. Should I be using DBD::DB2?
    >
    > 3. If so, what kind of drivers do I need to use DBD::DB2?
    >
    > Thanks for any help, as me and my boss have spent a good bit of time digging
    > through IBM sites, the Usenet, and the web. Thanks. Here's the bit of code
    > I'm using to "prototype" a connection:
    >
    >
    Code:
    > #!/usr/bin/perl -w
    >
    > use strict;
    > use DBI;
    >
    > my $db = DBI->connect('dbi:ODBC:AS400', 'myid', 'mypassword')  or die
    > $DBI::errstr;
    >
    > my $out = $db->prepare("SELECT * FROM CD02 WHERE CD02_INSTRNO = '4110'");
    > $out->execute() or die $DBI::errstr;
    >
    > while (my @lala = $out->fetchrow_array()) {
    >         foreach my $la (@lala) {
    >                 print "$la\t";
    >         }
    >
    >         print "\n";
    > }
    >
    > exit;
    >
    >
    > ...and here are the errors I get:
    >
    > [errors]
    > DBD::ODBC::db prepare failed: [unixODBC][IBM][iSeries Access ODBC Driver][DB2
    > UDB] (SQL-HY000)
    > [unixODBC][IBM][iSeries Access ODBC Driver][DB2 UDB] (SQL-42S02)(DBD:
    > st_prepare/SQLPrepare err=-1) at ./odbctest line 8.
    > Can't call method "execute" on an undefined value at ./odbctest line 9.
    > [/errors]
    >
    > Andrew Burton - tuglyraisin at aol dot com
    > Felecia Station on Harvestgain - [url]http://www.darkbeast.com/[/url]
    > "I often question my sanity; it has yet to give me a straight answer."
    > "And if you're bored, it's because... you're boring." - Matt Drudge
    Philip Nelson Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139