Subject: | Invalid string returned for CHAR columns |
Hi!
See the attached file. Script should print "10" but instead, it prints
"40", 30 spaces are appended to string.
Regards,
Tomasz
Subject: | firebirdtest.pl |
# Test table:
#
# CREATE TABLE TEST
# (
# CHAR_TEST CHAR( 10) CHARACTER SET UTF8
# );
#
# INSERT INTO TEST (CHAR_TEST) VALUES ('TEST');
#
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect(
'dbi:Firebird:db=C:\\sql\\test.fdb;host=localhost;port=3050;ib_charset=UTF8;',
'SYSDBA',
'masterkey',
{
ib_enable_utf8 => 1
}
)
or die $DBI::errstr;
my $sth = $dbh->prepare('SELECT CHAR_TEST FROM TEST;')
or die $DBI::errstr;
$sth->execute or die $DBI::errstr;
my $hashref = $sth->fetchrow_hashref;
print length $hashref->{CHAR_TEST};