我正在尝试使DBI的selectall_arrayref子例程返回不区分大小写的哈希键。例如:
my $dbh = DBI->connect('dbi:Oracle:' . 'host','user','pass',
{
RaiseError => 1,
PrintError => 0,
AutoCommit => 1
}
) || die( $DBI::errstr . "\n" );
$dbh->do('alter session set NLS_COMP=LINGUISTIC'); # this doesn't work
$dbh->do('alter session set NLS_SORT=BINARY_CI'); # this doesn't work
my $query = 'select test_id from test_table';
my $result = $dbh->selectall_arrayref($query, {Slice=>{}});
print(@$result[0]->{TEST_ID}); #works
print(@$result[0]->{test_id}); #does not work but I want to make it work
print(@$result[0]->{tEsT_Id}); #does not work but I want to make it work
我知道DBI具有此设置:
$dbh->{FetchHashKeyName} = 'NAME_uc' #upper case keys
$dbh->{FetchHashKeyName} = 'NAME_lc' #lower case keys
$dbh->{FetchHashKeyName} = 'NAME' #default
是的,如果我设置了其中之一,则它适用于相应的情况,但是我想以某种方式重写selectall_arrayref子例程以返回敏感的键,因此我可以使用小写,大写或小写和大写组合。
如何实现这样的目标?
我也想在DBI的其他子例程上实现这一点。
我目前正在使用DBD :: Oracle for Oracle和DBD :: Sybase for Microsoft SQL Server。
谢谢