Subject: | Inserting more than 127 utf8 characters into MS Access Text or Memo field gives "Invalid precision value" error |
When trying to insert more than 127 Unicode characters encoded as utf8
into a Text or Memo field the following error message is shown:
DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access
Driver]Invalid precision value (SQL-HY104)
Inserting 127 characters or less into the field works without any
problems.
This problem was encountered on .mbd files in MS Access 2000 and 2003
format.
I have attached a test script and some test data that reproduce the
error. The test script assumes that the database contains a table
UNICODE with the fields UNICODE_VARCHAR and UNICODE_TEXT.
UNICODE_VARCHAR should be a Text field with a size larger than 127.
UNICODE_TEXT should be a Memo field.
Subject: | test_unicode.pl |
#!perl
use strict;
use warnings;
use DBI;
my $access_dns = "driver={Microsoft Access Driver (*.mdb)};dbq=unicode.mdb";
my $dbh = DBI->connect( "DBI:ODBC:$access_dns" ) or die DBI->errstr();
my $insert_sql = 'INSERT INTO UNICODE ( UNICODE_VARCHAR, UNICODE_TEXT ) VALUES ( ?, ? )';
my $insert_stmt = $dbh->prepare( $insert_sql ) or die $dbh->errstr();
open my $UNICODE_DATA, '<:utf8', 'unicode_data.txt' or die $!;
while( my $line = <$UNICODE_DATA> ){
chomp( $line );
my @values = split ',', $line;
$insert_stmt->execute( @values ) or warn $dbh->errstr();
}
Subject: | unicode_data.txt |
ø,ø
øøøøø,øøøøø
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567,1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678,fails
fails,12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678