Thread

Posted on Tue Dec 19 08:33:39 2006 by ksanand
UTF8 encoding
Hello people, Here is the problem I am facing. In the following piece of code I get a customer name from the database and append a pound symbol to the customer name and update the same in the database. The NLS_LANG parameter is set to AMERICAN_AMERICA.WE8DEC (western European character set) When I query the database to see if the name has been updated correctly I see some garbage value appended to the name instead of just a pound symbol. Then I did some research to find out the version oralce DBD version being used is 1.12. I found some difference between 1.12 and 1.14 relating to unicode documentation. All I want to know is whether this was a bug in 1.12 which was fixed in the later version of 1.14 and will an upgrade to 1.14 fix this problem. Could anyone please confirm me on this? The closer I could get was to find this link http://search.cpan.org/dist/DBD-Oracle/Changes#___top. However the work around was to use "use Encoding" (Which is commented out in the following code) in perl which fixed the problem. Cheers, Anand.
use strict; use encoding 'utf8'; use atadb; use vars qw($opt_u); my $db = atadb::connect($opt_u); my $sql = " SELECT NODE_NAME FROM CUSTOMER_NODE_HISTORY WHERE CUSTOMER_NODE_ID = 9295370 "; my $csr = $db->prepare($sql) || ataerr::dbprepare($db); $csr->execute() || ataerr::dbexecute($db); my $node_name = $csr->fetchrow; $csr->finish; $node_name = 'wre'; my $pound = " \xc2\xa3"; print "Pound =>$pound\n"; my $node_name_upper = "\U$node_name\E".$pound; $node_name.=$pound; print "Node name".$node_name."\n";; print $node_name_upper."\n"; my $sql1 = "UPDATE CUSTOMER_NODE_HISTORY SET NODE_NAME = ? , NODE_NAME_UPPERCASE = ? WHERE CUSTOMER + +_NODE_ID = 9295370 "; my $csr1 = $db->prepare($sql1) || ataerr::dbprepare($db); print "Executing ... \n"; #use Encode; #$node_name = encode($ENV{PERL_ENCODING}, $node_name); #$node_name_upper = encode($ENV{PERL_ENCODING}, $node_name_upper); $csr1->execute($node_name, $node_name_upper) || ataerr::dbexecute($db); print "Committing ... \n"; $db->commit || die("commit: ".$db->errstr."\n"); $csr1->finish; $db->disconnect;
Direct Responses: 3835 | Write a response
Posted on Tue Dec 19 13:26:48 2006 by byterock in response to 3834
Re: UTF8 encoding
An ongoing problem, Upgrading to 1.14 my solve you problem but I cannot say for sure I am not familiar with the earlier code. You may find upgrading your Oracle client may fix it as well. By the way what version of Oracle and Oracle client are you using? Finally you would be much better off posting your question to dbi-users@perl.org, you don't need to subscribe in order to post, and you won't be automatically subscribed eitherr, as very few people use this form for dbi or driver support. dbi-users is where you'll get the best support
Direct Responses: 3866 | 3867 | Write a response
Posted on Thu Dec 21 08:40:23 2006 by ksanand in response to 3835
Re: UTF8 encoding
Many thanks for your response. Client version - SQL*Plus: Release 10.2.0.1.0 - Production on Thu Dec 21 16:31:14 2006 Oracle version - Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
Write a response
Posted on Thu Dec 21 08:41:54 2006 by ksanand in response to 3835
Re: UTF8 encoding
Many thanks for your response. Client version - SQL*Plus: Release 10.2.0.1.0 - Production on Thu Dec 21 16:31:14 2006 Oracle version - Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
Write a response