DBD-Oracle
DBD-Oracle copied to clipboard
TYPEs and attributes on bind_col are not sticky
#!/usr/bin/env perl use warnings;
use strict;
use Data::Dumper;
use DBI qw(neat :sql_types);
use DBD::Oracle qw(:ora_types);
my $h = DBI->connect('dbi:Oracle:host=aaa.bbb.local;sid=xxx', 'xxx','xxx', {RaiseError => 1});
my $s = $h->prepare(q/select 1,2 from dual/);
$s->execute;
$s->bind_col (1, undef, {TYPE => SQL_INTEGER, DiscardString => 1});
my $list = $s->fetchall_arrayref({});
print Dumper ($list);
produces:
$VAR1 = [
{ '1' => '1', <--------- NOTE it is a string
'2' => '2' } ];
but take the slice out of fetchall_arrayref and it produces:
$VAR1 = [
{ '1' => 1, <----- note a number
'2' => '2' } ];
It is down to DBI calling bind_col again on the columns for the slice and DBD::Oracle not making the type and attributes sticky.