blib/lib/OraSpriteFns.pl

filter: Statementstmt 4.1% 8 / 192 Branchbran 1.1% 1 / 84 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 6.8% 3 / 44 Podpod 0.0% 0 / 43 totaltotal 3.1% 12 / 377 CC 47 SCAR 40.5
CC
47
Cov
3%
TRUNC
272.0
LAST_DAY
42.0
INSTR
30.0
CRAP 57.2
« blib/lib/DBD/Sprite.pm ↑ Summary blib/lib/to_char.pl »
1 1 ▶use Time::Local;
Subroutine BEGIN: called CC=1 SCAR=0.0
2
3 sub ABS
4 0 ▶{
Subroutine ABS: not called CC=1 SCAR=6.9
Pod undocumented
5 0 return abs(shift);
6 }
7
8 sub ADD_MONTHS
9 0 ▶{
Subroutine ADD_MONTHS: not called CC=3 SCAR=24.8
Pod undocumented
10 0 my ($d, $n) = @_;
11 0 my @timestuff = localtime($d);
12 0 my ($mday) = $timestuff[3];
13 0 $d += (30*86400)*$n;
14 0 @timestuff = localtime($d);
15 0 my $thisdate = $timestuff[5] + 1900;
16 0 ▶ $thisdate .= '0' if ($timestuff[4] < 9);
Branch: 1 branch
BranchTrueFalseTotal
if $timestuff[4] < 9 0 0 0
17 0 $thisdate .= $timestuff[4] + 1;
18 0 ▶ $thisdate .= '0' if ($mday < 10);
Branch: 1 branch
BranchTrueFalseTotal
if $mday < 10 0 0 0
19 0 $thisdate .= $mday;
20 0 my $xx = timelocal(0,0,0,substr($thisdate,6,2),
21 (substr($thisdate,4,2)-1),substr($thisdate,0,4),0,0,0);
22 0 return $xx;
23
24 }
25
26 sub ASCII
27 0 ▶{
Subroutine ASCII: not called CC=1 SCAR=6.9
Pod undocumented
28 0 return ord(shift);
29 }
30
31 sub CEIL
32 0 ▶{
Subroutine CEIL: not called CC=2 SCAR=17.9
Pod undocumented
33 0 my $n = shift;
34 0 ▶ return int($n) + 1 if ($n > int($n));
Branch: 1 branch
BranchTrueFalseTotal
if $n > int $n 0 0 0
35 0 return int($n);
36 }
37
38 sub CHR
39 0 ▶{
Subroutine CHR: not called CC=1 SCAR=6.9
Pod undocumented
40 0 return chr(shift);
41 }
42
43 sub CONCAT
44 4 ▶{
Subroutine CONCAT: called CC=1 SCAR=0.0
Pod undocumented
45
46 #@_ = &chkcolumnparms(@_);
47 #return $_[0].$_[1];
48 4 return join('',@_);
49 }
50
51 sub COS
52 0 ▶{
Subroutine COS: not called CC=1 SCAR=6.9
Pod undocumented
53 0 return cos(shift);
54 }
55
56 sub CURDATE
57 0 ▶{
Subroutine CURDATE: not called CC=2 SCAR=17.9
Pod undocumented
58 0 ▶ my $fmt = shift || 'yyyy-mm-dd';
Condition0%0/2
shift() || 'yyyy-mm-dd'
l!l
00
MC/DC0%0/1
shift() || 'yyyy-mm-dd'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
59 0 return TO_CHAR(SYSTIME, $fmt)
60 }
61
62 sub DAYS_BETWEEN #SPRITE-ONLY FUNCTION.
63 0 ▶{
Subroutine DAYS_BETWEEN: not called CC=1 SCAR=6.9
Pod undocumented
64 0 my ($d1, $d2) = @_;
65 0 my ($secbtn) = abs($d2 - $d1);
66 0 return $secbtn / 86400;
67 }
68
69 sub EXP
70 0 ▶{
Subroutine EXP: not called CC=1 SCAR=6.9
Pod undocumented
71 0 return 2.71828183 ** shift;
72 }
73
74 sub FLOOR
75 0 ▶{
Subroutine FLOOR: not called CC=3 SCAR=24.8
Pod undocumented
76 0 my $n = shift;
77 0 ▶ return int($n) - 1 if ($n < 0 && $n < int($n));
Branch: 1 branch
BranchTrueFalseTotal
if $n < 0 and $n < int $n 0 0 0
Condition0%0/3
$n < 0 and $n < int $n
!ll&&!rl&&r
000
MC/DC0%0/2
$n < 0 and $n < int $n
$n < 0 $n < int $n
Truth table0%0/3
A and B
A= $n < 0B= $n < int $n
ABresult
0X0
100
111
78 0 return int($n);
79 }
80
81 sub INITCAP
82 0 ▶{
Subroutine INITCAP: not called CC=1 SCAR=6.9
Pod undocumented
83 0 my ($s) = shift;
84 0 $s =~ s/\b(\w)(\w*)/\U$1\L$2\E/g;
85 0 return $s;
86 }
87
88 sub INSTR
89 0 ▶{
Subroutine INSTR: not called CC=5 SCAR=34.0
Pod undocumented
90 0 my ($s, $srch, $n, $m) = @_;
91 0 my $t = $n;
92 0 ▶ if ($n < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($n < 0) 0 0 0
93 {
94 0 $s = reverse($s);
95 0 $srch = reverse($srch);
96 0 $t = abs($n);
97 }
98 0 ▶ for (my $i=1;$i<=$m;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $m) 0 0 0
99 {
100 0 $t = index($s, $srch, $t) + 1;
101 0 ▶ return 0 if ($t < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $t < 0 0 0 0
102 }
103 0 ▶ return length($s) - $t if ($n < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $n < 0 0 0 0
104 0 return $t;
105 }
106
107 sub INSTRB
108 0 ▶{
Subroutine INSTRB: not called CC=1 SCAR=6.9
Pod undocumented
109 0 return INSTR(@_);
110 }
111
112 sub LAST_DAY
113 0 ▶{
Subroutine LAST_DAY: not called CC=6 SCAR=37.4
Pod undocumented
114 0 my ($t) = shift;
115
116 0 my @timestuff = localtime($t);
117 0 my @lastdate = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
118 0 my $thisdate = $timestuff[5] + 1900;
119 0 ▶ $thisdate .= '0' if ($timestuff[4] < 9);
Branch: 1 branch
BranchTrueFalseTotal
if $timestuff[4] < 9 0 0 0
120 0 $thisdate .= $timestuff[4] + 1;
121 #$thisdate .= '0' if ($timestuff[3] < 10);
122 #$thisdate .= $timestuff[3];
123 0 ▶ if ($timestuff[4] == 1)
Branch: 1 branch
BranchTrueFalseTotal
if ($timestuff[4] == 1) { } 0 0 0
124 {
125 0 ▶ if (!(($timestuff[5]+300) % 400))
Branch: 3 branches
BranchTrueFalseTotal
if (not +($timestuff[5] + 300) % 400) { } 0 0 0
elsif (not $timestuff[5] % 100) { } 0 0 0
elsif (not $timestuff[5] % 4) { } 0 0 0
126 {
127 0 $thisdate .= '29';
128 }
129 elsif (!($timestuff[5] % 100))
130 {
131 0 $thisdate .= '28';
132 }
133 elsif (!($timestuff[5] % 4))
134 {
135 0 $thisdate .= '29';
136 }
137 else
138 {
139 0 $thisdate .= '28';
140 }
141 }
142 else
143 {
144 0 $thisdate .= $lastdate[$timestuff[4]];
145 }
146 0 my $xx = timelocal(0,0,0,substr($thisdate,6,2),
147 (substr($thisdate,4,2)-1),substr($thisdate,0,4),0,0,0);
148 0 return $xx;
149 }
150
151 sub LENGTH
152 0 ▶{
Subroutine LENGTH: not called CC=1 SCAR=6.9
Pod undocumented
153 0 return length(shift);
154 }
155
156 sub LENGTHB
157 0 ▶{
Subroutine LENGTHB: not called CC=1 SCAR=6.9
Pod undocumented
158 0 return length(shift);
159 }
160
161 sub LPAD
162 0 ▶{
Subroutine LPAD: not called CC=1 SCAR=6.9
Pod undocumented
163 0 my ($s, $l, $p) = @_;
164 0 my $t = $p x $l;
165 0 return substr($t,0,($l-length($s))) . $s;
166 }
167
168 sub LTRIM
169 0 ▶{
Subroutine LTRIM: not called CC=1 SCAR=6.9
Pod undocumented
170 0 my ($x, $y) = @_;
171 0 $x =~ s/^[$y]+//;
172 0 return $x;
173 }
174
175 sub LOWER
176 0 ▶{
Subroutine LOWER: not called CC=1 SCAR=6.9
Pod undocumented
177 #@_ = &chkcolumnparms(@_);
178 0 my ($s) = shift;
179 0 $s =~ tr/A-Z/a-z/;
180 0 return $s;
181 }
182
183 sub MOD
184 0 ▶{
Subroutine MOD: not called CC=2 SCAR=17.9
Pod undocumented
185 0 my ($m, $n) = @_;
186 0 ▶ return $m unless ($n);
Branch: 1 branch
BranchTrueFalseTotal
unless $n 0 0 0
187 0 return $m % $n;
188 }
189
190 sub MONTHS_BETWEEN #ASSUMES 30-DAY MONTHS - APPROXIMATES THE ORACLE FUNCTION!
191 0 ▶{
Subroutine MONTHS_BETWEEN: not called CC=1 SCAR=6.9
Pod undocumented
192 0 my ($d1, $d2) = @_;
193 0 my ($secbtn) = abs($d2 - $d1);
194 0 return $secbtn / (30*86400);
195 }
196
197 sub NOW
198 0 ▶{
Subroutine NOW: not called CC=2 SCAR=17.9
Pod undocumented
199 0 ▶ my $fmt = shift || 'yyyy-mm-dd hh:mi:ss';
Condition0%0/2
shift() || 'yyyy-mm-dd hh:mi:ss'
l!l
00
MC/DC0%0/1
shift() || 'yyyy-mm-dd hh:mi:ss'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
200 0 return TO_CHAR(SYSTIME, $fmt)
201 }
202
203 sub now
204 0 ▶{
Subroutine now: not called CC=2 SCAR=17.9
Pod undocumented
205 0 ▶ my $fmt = shift || 'yyyy-mm-dd hh:mi:ss';
Condition0%0/2
shift() || 'yyyy-mm-dd hh:mi:ss'
l!l
00
MC/DC0%0/1
shift() || 'yyyy-mm-dd hh:mi:ss'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
206 0 return TO_CHAR(SYSTIME, $fmt)
207 }
208
209 sub NVL #CHGD. TO LAST LINE 20040325 TO MAKE WORK LIKE ORACLE!?
210 0 ▶{
Subroutine NVL: not called CC=2 SCAR=17.9
Pod undocumented
211 # my (@parms) = @_;
212 # my ($t);
213 # while ($#parms >= 0)
214 # {
215 # $t = shift(@parms);
216 # return $t if (defined($t) && $t ne '');
217 # }
218 # return defined($t) ? $t : '';
219 0 ▶ return (length($_[0]) ? $_[0] : $_[1]);
Branch: 1 branch
BranchTrueFalseTotal
length $_[0] ? : 0 0 0
220 }
221
222 sub POWER
223 0 ▶{
Subroutine POWER: not called CC=1 SCAR=6.9
Pod undocumented
224 0 return $_[0] ** $_[1];
225 }
226
227 sub REPLACE
228 0 ▶{
Subroutine REPLACE: not called CC=2 SCAR=17.9
Pod undocumented
229 0 my ($s, $x, $y) = (@_[0..2]);
230 0 ▶ if ($_[3] eq 'i')
Branch: 1 branch
BranchTrueFalseTotal
if ($_[3] eq 'i') { } 0 0 0
231 {
232 0 $s =~ s/\Q$x\E/\Q$y\E/ig; #SPRITE EXTENSION, NOT SUPPORTED IN ORACLE!
233 }
234 else
235 {
236 0 $s =~ s/\Q$x\E/\Q$y\E/g;
237 }
238 0 return $s;
239 }
240
241 sub ROUND
242 0 ▶{
Subroutine ROUND: not called CC=2 SCAR=17.9
Pod undocumented
243 0 my ($m, $n) = @_;
244 0 ▶ return sprintf("%.${n}f", $m) if ($n >= 0);
Branch: 1 branch
BranchTrueFalseTotal
if $n >= 0 0 0 0
245 0 $m *= 10 ** $n;
246 0 return (1 * sprintf('%.0f', $m)) / (10 ** $n);
247 }
248
249 sub RPAD
250 0 ▶{
Subroutine RPAD: not called CC=2 SCAR=17.9
Pod undocumented
251 0 my ($s, $l, $p) = @_;
252 0 ▶ while (length($s) < $l)
Branch: 1 branch
BranchTrueFalseTotal
if (length $s < $l) 0 0 0
253 {
254 0 $s .= $p;
255 }
256 0 return substr($s, 0, $l);
257 }
258
259 sub RTRIM
260 0 ▶{
Subroutine RTRIM: not called CC=1 SCAR=6.9
Pod undocumented
261 0 my ($x, $y) = @_;
262 0 $x =~ s/[$y]+$//;
263 0 return $x;
264 }
265
266 sub SIGN
267 0 ▶{
Subroutine SIGN: not called CC=3 SCAR=24.8
Pod undocumented
268 0 ▶ return -1 if ($_[0] < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] < 0 0 0 0
269 0 ▶ return 0 unless ($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] 0 0 0
270 0 return 1;
271 }
272
273 sub SIN
274 0 ▶{
Subroutine SIN: not called CC=1 SCAR=6.9
Pod undocumented
275 0 return sin(shift);
276 }
277
278 sub SQRT
279 0 ▶{
Subroutine SQRT: not called CC=1 SCAR=6.9
Pod undocumented
280 0 return sqrt(shift);
281 }
282
283 sub SUBSTR
284 0 ▶{
Subroutine SUBSTR: not called CC=4 SCAR=30.0
Pod undocumented
285 #@_ = &chkcolumnparms(@_);
286 0 my ($s) = shift;
287 0 my ($p) = shift;
288 #($s, $p) = &chkcolumnparms(@_);
289
290 0 ▶ return '' unless ($p);
Branch: 1 branch
BranchTrueFalseTotal
unless $p 0 0 0
291
292 0 ▶ --$p if ($p > 0);
Branch: 1 branch
BranchTrueFalseTotal
if $p > 0 0 0 0
293
294 0 my ($l) = shift;
295 0 ▶ return (substr($s, $p)) unless ($l);
Branch: 1 branch
BranchTrueFalseTotal
unless $l 0 0 0
296 0 return substr($s, $p, $l);
297 }
298
299 sub SUBSTRB
300 0 ▶{
Subroutine SUBSTRB: not called CC=1 SCAR=6.9
Pod undocumented
301 0 return SUBSTR(@_);
302 }
303
304 sub TO_CHAR
305 1 ▶{
Subroutine TO_CHAR: called CC=2 SCAR=9.2
Pod undocumented
306 1 do 'to_char.pl';
307 1 ▶ if ($err =~ /^Invalid/)
Branch: 1 branch
BranchTrueFalseTotal
if ($err =~ /^Invalid/) 0 1 1
308 {
309 0 $errdetails = $err;
310 0 $rtnTime = '';
311 0 $self->display_error(-503);
312 }
313 1 return $rtnTime;
314 }
315
316 sub TO_DATE
317 0 ▶{
Subroutine TO_DATE: not called CC=2 SCAR=17.9
Pod undocumented
318 0 do 'to_date.pl';
319 0 ▶ if ($err =~ /^Invalid/)
Branch: 1 branch
BranchTrueFalseTotal
if ($err =~ /^Invalid/) 0 0 0
320 {
321 0 $errdetails = $err;
322 0 $rtnTime = '';
323 0 $self->display_error(-503);
324 }
325 0 return $rtnTime;
326 }
327
328 sub TO_NUMBER
329 0 ▶{
Subroutine TO_NUMBER: not called CC=3 SCAR=24.8
Pod undocumented
330 0 $rtnTime = shift;
331 0 my $fmt = shift;
332
333 0 my $fmtstr = 'f';
334 0 ▶ $fmtstr = $1 if ($rtnTime =~ s/(e)eee//i);
Branch: 1 branch
BranchTrueFalseTotal
if $rtnTime =~ s/(e)eee//i 0 0 0
335 0 $rtnTime =~ s/[^\d\.\+\-Vv]//g;
336 0 my $dec = 0;
337 0 ▶ $dec = length($2) if ($fmt =~ /([\d\+\-]*)V(\d*)/);
Branch: 1 branch
BranchTrueFalseTotal
if $fmt =~ /([\d\+\-]*)V(\d*)/ 0 0 0
338 #my ($dec) = length($2);
339 0 $rtnTime *= (10 ** $dec);
340 0 return sprintf('%.0f',$rtnTime); #ROUND IT.
341 0 return $rtnTime;
342 }
343
344 sub TRANSLATE
345 0 ▶{
Subroutine TRANSLATE: not called CC=1 SCAR=6.9
Pod undocumented
346 0 my ($s, $a, $b) = @_;
347 0 eval "\$s =~ tr/$a/$b/d";
348 0 return $s;
349 }
350
351 sub TRUNC
352 0 ▶{
Subroutine TRUNC: not called CC=16 SCAR=56.1
Pod undocumented
353 0 my ($m, $n) = @_;
354 0 ▶ if ($n =~ /D/i)
Branch: 5 branches
BranchTrueFalseTotal
if ($n =~ /D/i) { } 0 0 0
elsif ($n =~ /Y/i) { } 0 0 0
elsif ($n =~ /MI/i) { } 0 0 0
elsif ($n =~ /M/i) { } 0 0 0
elsif ($n =~ /H/i) { } 0 0 0
355 {
356 0 my @timestuff = localtime($m);
357 0 my $thisdate = $timestuff[5] + 1900;
358 0 ▶ $thisdate .= '0' if ($timestuff[4] < 9);
Branch: 1 branch
BranchTrueFalseTotal
if $timestuff[4] < 9 0 0 0
359 0 $thisdate .= $timestuff[4] + 1;
360 0 ▶ $thisdate .= '0' if ($timestuff[3] < 10);
Branch: 1 branch
BranchTrueFalseTotal
if $timestuff[3] < 10 0 0 0
361 0 $thisdate .= $timestuff[3];
362 0 my $xx = timelocal(0,0,0,substr($thisdate,6,2),
363 (substr($thisdate,4,2)-1),substr($thisdate,0,4),0,0,0);
364 0 return $xx;
365 }
366 elsif ($n =~ /Y/i)
367 {
368 0 my @timestuff = localtime($m);
369 0 my $thisdate = $timestuff[5] + 1900;
370 0 my $xx = timelocal(0,0,0,1,0,$thisdate,0,0,0);
371 0 return $xx;
372 }
373 elsif ($n =~ /MI/i)
374 {
375 0 my @timestuff = localtime($m);
376 0 my $thisdate = $timestuff[5] + 1900;
377 0 ▶ $thisdate .= '0' if ($timestuff[4] < 9);
Branch: 1 branch
BranchTrueFalseTotal
if $timestuff[4] < 9 0 0 0
378 0 $thisdate .= $timestuff[4] + 1;
379 0 ▶ $thisdate .= '0' if ($timestuff[3] < 10);
Branch: 1 branch
BranchTrueFalseTotal
if $timestuff[3] < 10 0 0 0
380 0 $thisdate .= $timestuff[3];
381 0 ▶ $thisdate .= '0' if ($timestuff[2] < 10);
Branch: 1 branch
BranchTrueFalseTotal
if $timestuff[2] < 10 0 0 0
382 0 $thisdate .= $timestuff[2];
383 0 ▶ $thisdate .= '0' if ($timestuff[1] < 10);
Branch: 1 branch
BranchTrueFalseTotal
if $timestuff[1] < 10 0 0 0
384 0 $thisdate .= $timestuff[1];
385 0 my $xx = timelocal(0,substr($thisdate,10,2),substr($thisdate,8,2),substr($thisdate,6,2),
386 (substr($thisdate,4,2)-1),substr($thisdate,0,4),0,0,0);
387 0 return $xx;
388 }
389 elsif ($n =~ /M/i)
390 {
391 0 my @timestuff = localtime($m);
392 0 my $thisdate = $timestuff[5] + 1900;
393 0 ▶ $thisdate .= '0' if ($timestuff[4] < 9);
Branch: 1 branch
BranchTrueFalseTotal
if $timestuff[4] < 9 0 0 0
394 0 $thisdate .= $timestuff[4] + 1;
395 0 my $xx = timelocal(0,0,0,1,(substr($thisdate,4,2)-1),substr($thisdate,0,4),0,0,0);
396 0 return $xx;
397 }
398 elsif ($n =~ /H/i)
399 {
400 0 my @timestuff = localtime($m);
401 0 my $thisdate = $timestuff[5] + 1900;
402 0 ▶ $thisdate .= '0' if ($timestuff[4] < 9);
Branch: 1 branch
BranchTrueFalseTotal
if $timestuff[4] < 9 0 0 0
403 0 $thisdate .= $timestuff[4] + 1;
404 0 ▶ $thisdate .= '0' if ($timestuff[3] < 10);
Branch: 1 branch
BranchTrueFalseTotal
if $timestuff[3] < 10 0 0 0
405 0 $thisdate .= $timestuff[3];
406 0 ▶ $thisdate .= '0' if ($timestuff[2] < 10);
Branch: 1 branch
BranchTrueFalseTotal
if $timestuff[2] < 10 0 0 0
407 0 $thisdate .= $timestuff[2];
408 0 my $xx = timelocal(0,0,substr($thisdate,8,2),substr($thisdate,6,2),
409 (substr($thisdate,4,2)-1),substr($thisdate,0,4),0,0,0);
410 0 return $xx;
411 }
412 else
413 {
414 0 return int($m * (10 ** $n)) / (10 ** $n);
415 }
416 }
417
418 sub UPPER
419 0 ▶{
Subroutine UPPER: not called CC=1 SCAR=6.9
Pod undocumented
420 0 my ($s) = shift;
421 0 $s =~ tr/a-z/A-Z/;
422 0 return $s;
423 }
424
425 sub WEEKS_BETWEEN #SPRITE-ONLY FUNCTION.
426 0 ▶{
Subroutine WEEKS_BETWEEN: not called CC=1 SCAR=6.9
Pod undocumented
427 0 my ($d1, $d2) = @_;
428 0 my ($secbtn) = abs($d2 - $d1);
429 0 return $secbtn / (7*86400);
430 }
431
432 sub YEARS_BETWEEN #SPRITE-ONLY FUNCTION.
433 0 ▶{
Subroutine YEARS_BETWEEN: not called CC=1 SCAR=6.9
Pod undocumented
434 0 my ($d1, $d2) = @_;
435 0 my ($secbtn) = abs($d2 - $d1);
436 0 return $secbtn / (365.25*86400);
437 }
438
439 1 1
« blib/lib/DBD/Sprite.pm ↑ Summary blib/lib/to_char.pl »