Subject: | type_info and type_info_all miss vital information |
type_info () and type_info_all miss info for BLOB and CLOB (and maybe
more). When writing portable scripts, you want to rely upon valid data
in that!
--8<---
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect ("dbi:Oracle:", (split m{/}, $ENV
{ORACLE_USERID}), {
RaiseError => 1,
PrintError => 1,
ShowErrorStatement => 1,
AutoCommit => 1,
ChopBlanks => 1,
# InhibitNULL => 9,
FetchHashKeyName => "NAME_lc",
}) or die "Cannot connect: $!\n";
$dbh->do (q;
create table test_foo (
i integer,
n3 numeric (3),
n52 numeric (5, 2),
d decimal,
ch4 char (4),
vc4 varchar2 (4),
cl clob,
bl blob,
fl float
););
my $sth = $dbh->prepare ("select * from test_foo");
$sth->execute;
my @nm = @{$sth->{NAME_lc}};
my @tp = @{$sth->{TYPE}};
my @pr = @{$sth->{PRECISION}};
my @sc = @{$sth->{SCALE}};
foreach my $i (0 .. $#nm) {
my @ti = $dbh->type_info ($tp[$i]);
my $st = @ti == 1 ? $ti[0]{TYPE_NAME} : "?";
printf "%d: %-5s %3d:%-20s (%3d, %2d)\n",
$i, $nm[$i], $tp[$i], $st, $pr[$i], $sc[$i];
}
$sth->finish;
$dbh->do ("drop table test_foo");
-->8---
=>
0: i 3:DECIMAL ( 38, 0)
1: n3 3:DECIMAL ( 3, 0)
2: n52 3:DECIMAL ( 5, 2)
3: d 3:DECIMAL ( 38, 0)
4: ch4 1:CHAR ( 4, 0)
5: vc4 12:VARCHAR2 ( 4, 0)
6: cl 40:? ( 0, 0)
7: bl 30:? ( 0, 0)
8: fl 8:DOUBLE PRECISION (126, 0)