Re: PERL DBI documentatio -- how to check for errors

Jochen Wiedmann <[email protected]>
Newsgroups gmane.comp.db.mysql.perl
Message-ID <[email protected]>
On 11/18/05, Nitzan Shaked <[email protected]> wrote:

> Now, *everybody* knows you don't go around changing the structure of a large
> existing system. I *am* willing to change "$rv or die..." to "defined $rv or
> die...". Or similar changes.

No problem. Set the "RaiseError" flag locally, as in:

        my $dbh;
        # Performs a database operation, using the database handle $dbh
        # We don't know the state of $dbh, but presumably it has "RaiseError"
        # turned off. But we may turn it on within the following block:
        {
            local $dbh->{"RaiseError"} = 1;
            eval {
                 # Do one or more database operations here ...
            };
            if ($@) { ... }
        }

Note, that you might even encapsulate this in a separate method.


Jochen


--
Often it does seem a pity that Noah and his party did not miss the
boat. (Mark Twain)

-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.