in reply to Re: Issue while inserting Thai Characters into Database..
in thread Issue while inserting Thai Characters into Database..

Hi Alexander/mje

Thanks for your responses and guidance.
Now i have changed to 3 argument open statement, by this avoided using decode_utf8() method.
I have downloaded DBD::ODBC v1.23 . I am also installing VC++ to compile it.
I have gone through READMEs of both 1.16 and 1.23, i see odbc_utf8_on flag in latest version. I will continue solving my problem after installing 1.23 and update the status.

Thanks,
Ajay
  • Comment on Re^2: Issue while inserting Thai Characters into Database..

Replies are listed 'Best First'.
Re^3: Issue while inserting Thai Characters into Database..
by mje (Curate) on Jan 20, 2010 at 08:59 UTC

    Best of luck - will wait to hear what progress you make.

      Thanks much Martin.
      I have installed ver1.23 and made changes suggested by you.

      #!/usr/bin/perl use DBI; use Encode; my $AbsFileName = "E:\\Ajay\\sample\\sample\.pnx"; if (-e "$AbsFileName") { my ($DSN,$dbh,$sth); $dbh = DBI->connect("dbi:ODBC:DSN=<DSN>;UID=<USER>;PWD=<PASSWD +>") or die "$DBI::errstr\n"; $dbh->{odbc_utf8_on} = 1; my $sth = $dbh->prepare(<<SQL) or die "$DBI::errstr\n"; INSERT INTO BK_imageINfo (CustFld1,CustFld2,CustFld3,CustFld4, +CustFld5,CustFld6,CustFld7,CustFld8,CustFld9,CustFld10,CustFld11,Cust +Fld12,Efield1,Efield2,Efield3,Efield4,Efield5) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) SQL open INFILE, "<:encoding(UTF-8)", "$AbsFileName" or die "Can't + open File $AbsFileName for reading: $!\n"; while (my $data = <INFILE>) { chomp($data); my ($cfd1, $cfd2, $cfd3, $cfd4, $cfd5, $cfd6, $cfd7, $cfd8 +, $cfd9, $cfd10, $cfd11, $cfd12, $enr1, $enr2, $enr3, $enr4, $enr5) = + split /:/, $data; my $outfl = "E:\\Ajay\\sample\\query.txt"; open OUTFILE, ">>:encoding(UTF-8)", "$outfl" or die "Can't + open File $outfl for writing: $!\n"; my $sql = "INSERT INTO BK_imageINfo (CustFld1,CustFld2,Cus +tFld3,CustFld4,CustFld5,CustFld6,CustFld7,CustFld8,CustFld9,CustFld10 +,CustFld11,CustFld12,Efield1,Efield2,Efield3,Efield4,Efield5) VALUES +($cfd1, $cfd2, $cfd3, $cfd4, $cfd5, $cfd6, $cfd7, $cfd8, $cfd9, $cfd1 +0, $cfd11, $cfd12, $enr1, $enr2, $enr3, $enr4, $enr5)"; print OUTFILE "\n$sql\n"; close OUTFILE; $sth->execute($cfd1, $cfd2, $cfd3, $cfd4, $cfd5, $cfd6, $c +fd7, $cfd8, $cfd9, $cfd10, $cfd11, $cfd12, $enr1, $enr2, $enr3, $enr4 +, $enr5) or die "$DBI::errstr\n"; } close INFILE; #Close the database $sth->finish; $dbh->disconnect; } else { print "\n\n $AbsFileName doesn't exists\n"; }
      Above code is working fine and i am able to insert Thai characters successfully. But i do have a DATETIME column in database. I am getting the error "DBD::ODBC::st execute failed: MicrosoftODBC SQL Server DriverInvalid character value for cast specification (SQL-22018)" when i insert value to date field.

      Thanks,
      Ajay