Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • by derby (3342) on 2003.09.17 10:36 (#24269)
    If the get_connection method returns a handle
    on which RaiseError, was set, just wrap in
    an eval:

    sub GetValues {
          my $a;

          eval {
                  my $dbh = get_connection('databasename');
                  my $sth = $dbh->prepare('Select * from table_name');
                  $sth->execute();
                  my $r;
                  while ($r = $sth->fetchrow_hashref) {
                        push @$a, $r;
                  }
          };

          print STDERR $@ if $@;
          return $@ ? undef : $a;
    }
    --
    -derby