dbMan/Extension/OracleSQL.pm untested

filter: Statementstmt 0.0% 0 / 54 Branchbran 0.0% 0 / 38 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 121 CC 20 SCAR 58.2
CC
20
Cov
0%
handle_action
420.0
IDENTIFICATION
2.0
preference
2.0
CRAP 336.4
1 package DBIx::dbMan::Extension::OracleSQL;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.11';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000038-000011"; }
11  
12 sub preference { return 3999; }
13  
14 sub known_actions { return [ qw/COMMAND SQL/ ]; }
15  
16 sub handle_action {
17 my ($obj,%action) = @_;
18  
19 if ($action{action} eq 'COMMAND' and $obj->{-dbi}->driver eq 'Oracle') {
20 $action{processed} = 1;
21 $obj->{-dbi}->set('LongTruncOk',1);
22 if ($obj->{-mempool}->get('dbms_output')) {
23 $obj->{-dbi}->func(1000000,'dbms_output_enable');
24 $action{oracle_dbms} = 1;
25 }
26 if ($action{cmd} !~ /end;$/i) {
27 return %action if $action{cmd} =~ s/(;|(?<!\*)\/)$//;
28 }
29 }
30 if ($action{action} eq 'SQL' and $action{oper} eq 'complete' and $obj->{-dbi}->driver eq 'Oracle') {
31 $action{action} = 'CACHE';
32 my @all = ();
33 if ($action{context} =~ /\./) {
34 $action{cache_type} = 'sql_oracle_' . $action{type} . '___' . $action{context};
35 my $tab = $action{context}; $tab =~ s/\.[^.]*$//;
36 my $sth = $obj->{-dbi}->prepare(q!SELECT * FROM !.$tab.q! WHERE 0 = 1!);
37 if (defined $sth and not @all) {
38 if ($sth->execute) {
39 @all = map { ($action{type} eq 'FIELDS') ? $_ : $tab.'.'.$_ } @{$sth->{NAME}};
40 $sth->finish;
41 } elsif (lc $action{type} eq 'seq') { # don't work ??? why ???
42 if ($tab !~ /\./) { @all = map { $tab.'.'.$_ } qw/next_val curr_val/; }
43 }
44 } else {
45 my $d = $obj->{-dbi}->selectall_arrayref(q!
46 SELECT object_name
47 FROM all_objects
48 WHERE owner = ? AND object_type !.(lc $action{type} ne 'object'?((lc $action{type} eq 'context')?q! IN ('TABLE','VIEW','FUNCTION','PACKAGE')!:((lc $action{type} eq 'seq')?q! = 'SEQUENCE'!:q! = '!.uc($action{type}).q!'!)):q!IN ('PROCEDURE','FUNCTION','TRIGGER','VIEW','PACKAGE','PACKAGE BODY')!),{},uc $tab);
49 @all = map { uc($tab).'.'.$_->[0] } @$d if defined $d;
50 }
51 } else {
52 $action{cache_type} = 'sql_oracle_' . $action{type};
53 my $d = $obj->{-dbi}->selectall_arrayref(q!
54 SELECT object_name
55 FROM user_objects
56 WHERE object_type !.(lc $action{type} ne 'object'?((lc $action{type} eq 'context')?q! IN ('TABLE','VIEW','FUNCTION','PACKAGE')!:((lc $action{type} eq 'seq')?q! = 'SEQUENCE'!:q! = '!.uc($action{type}).q!'!)):q!IN ('PROCEDURE','FUNCTION','TRIGGER','VIEW','PACKAGE','PACKAGE BODY')!));
57 @all = map { $_->[0] } @$d if defined $d;
58 push @all,'DUAL';
59 push @all,'SYSDATE';
60 }
61 $action{list} = \@all;
62 }
63 $action{processed} = 1;
64 return %action;
65 }