Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2002
    Posts
    7

    Unanswered: DB2/win32: Raiseerror and $handle->errstr()

    Hello,

    I use
    $x->execute() or
    print 'Error:',$dbh->errstr();
    to show an error to my user.
    but the error is always:
    [IBM][CLI Driver] CLI0125E Function sequence error. SQLSTATE=HY010

    If I want to see the real errormessage I have to initialize my DB2 connection with 'RaiseError => 1'.
    But now the script stops and show me the error without running the rest of my script :(
    on the website I see now:
    Software error:
    DBD::DB2::db prepare failed: [IBM][CLI Driver][DB2/NT] SQL0104N
    with Problemdescription ...

    all I want ... BUT the script stopps!!

    Can I get these detailed errormessage without stopping of my script??
    And how can I get this?

  2. #2
    Join Date
    Feb 2001
    Location
    NC, USA
    Posts
    200
    Wrap the call in an 'eval' and then check for $@

    like so:
    Code:
    sub db_execute {
        my $sql = $_[0];
        my $ignore_when_fail = $_[1];
        eval { $dbh->do($sql) };
        if ($@) {
           if(defined($ignore_when_fail)) {
               print "\nQuery failed:\n$sql\n\n$@";
               return 0;
           } else { die "\nQuery failed:\n$sql\n\n$@"; }
        }
        return 1;
    }

  3. #3
    Join Date
    Sep 2002
    Posts
    7

    Thumbs up

    thanks ...

Posting Permissions

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