SPOPS/DBI/Oracle.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 47 CC 4 SCAR 21.5
CC
4
Cov
0%
pre_fetch_id
20.0
sql_current_date
2.0
post_fetch_id
2.0
CRAP 8.5
1 package SPOPS::DBI::Oracle;
2  
3 # $Id: Oracle.pm,v 3.6 2004/06/02 00:48:22 lachoy Exp $
4  
5 use strict;
6 use SPOPS::Exception qw( spops_error );
7 use SPOPS::Utility;
8  
9 $SPOPS::DBI::Oracle::VERSION = sprintf("%d.%02d", q$Revision: 3.6 $ =~ /(\d+)\.(\d+)/);
10  
11 sub sql_current_date { return SPOPS::Utility->now() }
12  
13 use constant ORA_SEQUENCE_NEXT => 'SELECT %s.NextVal FROM dual';
14 use constant ORA_SEQUENCE_CURRENT => 'SELECT %s.CurrVal FROM dual';
15  
16 sub pre_fetch_id {
17 my ( $item, $p ) = @_;
18 my ( $seq_name );
19 return undef unless ( $item->CONFIG->{increment_field} );
20 return undef unless ( $seq_name = $item->CONFIG->{sequence_name} );
21 my ( $sth );
22 eval {
23 $sth = $p->{db}->prepare( sprintf( ORA_SEQUENCE_NEXT, $seq_name ) );
24 $sth->execute;
25 };
26 if ( $@ ) {
27 spops_error "Failed to retrieve ID from sequence '$seq_name': $@";
28 }
29 return ( $sth->fetchrow_arrayref->[0], undef );
30 }
31  
32  
33 sub post_fetch_id {
34 return undef;
35 }
36  
37 1;
38  
39 __END__