File Coverage

blib/lib/ResourcePool/Command/DBI/Select.pm
Criterion Covered Total %
statement 18 32 56.2
branch 0 4 0.0
condition 0 6 0.0
subroutine 6 7 85.7
pod 1 1 100.0
total 25 50 50.0


line stmt bran cond sub pod time code
1             #*********************************************************************
2             #*** lib/ResourcePool/Command/DBI/Select.pm
3             #*** Copyright (c) 2004 by Markus Winand
4             #*** $Id: Select.pm,v 1.4 2004/05/02 07:48:55 mws Exp $
5             #*********************************************************************
6             package ResourcePool::Command::DBI::Select;
7              
8 2     2   65296 use ResourcePool::Command;
  2         557  
  2         129  
9 2     2   944 use ResourcePool::Command::NoFailoverException;
  2         295  
  2         45  
10 2     2   712 use ResourcePool::Command::DBI::Common;
  2         4  
  2         55  
11 2     2   12 use strict;
  2         13  
  2         66  
12 2     2   10 use DBI;
  2         4  
  2         198  
13 2     2   12 use vars qw(@ISA $VERSION);
  2         3  
  2         576  
14              
15             $VERSION = "1.0101";
16             push @ISA, qw(ResourcePool::Command::DBI::Common ResourcePool::Command);
17              
18             sub execute($$@) {
19 0     0 1   my ($self, $dbh, @args) = @_;
20              
21 0           my $sql = $self->getSQLfromargs(\@args);
22 0           my $sth = $self->prepare($dbh, $sql);
23              
24 0           $self->bind($sth, \@args);
25              
26 0           my $rc = 1;
27 0           eval {
28 0           $rc = $sth->execute();
29             };
30              
31 0 0 0       if ($rc && ! $@) {
32 0           return $sth;
33             } else {
34             # test if failover should occure
35 0           eval {
36 0           $rc = $dbh->ping();
37             };
38 0 0 0       if ($rc && !$@) {
39 0           die 'Execution of "' . $sql . '" failed: ' . $sth->errstr() . "\n";
40             } else {
41 0           die ResourcePool::Command::NoFailoverException->new(
42             'Execution of "' . $sql . '" failed: ' . $sth->errstr() . "\n"
43             );
44             }
45             }
46             }
47              
48              
49             1;