|
|
sybperl-l Archive
Up Prev Next
From: Gary Chen <f2ind at yahoo dot com>
Subject: How To Send String in UTF-8 Format to Sybase
Date: Mar 8 2001 8:28PM
I wrote a test program which reads in text string and
translates it into UTF8 format and sends to Sybase,
which stores the data in UTF8 format.
I have open a db connection without error by using the
following:
$dbh = new Sybase::CTlib $uid, $pw, $svr, 't_utf',
{CON_PROPS => {
CS_HOSTNAME() => 'test.db',
CS_SYB_CHARSET() => 'utf8' }};
....
Then I try:
use utf8;
open( INFILE, $file ) or die "Couldn't open $file:
$!";
while () {
chomp;
no warnings utf8;
tr/\0-\xff//CU;
print "$_\n";
$sql="select areaId from areas where
areaId="."\'$_\'";
print "$sql\n";
$dbh->ct_execute($sql);
...
}
Part of the output:
dbh is Sybase::CTlib=HASH(0x212504)
ct_command retcode: 1
ct_send retcode: 1
retcode is 1; restype is 4047
retcode is 1; restype is 4046
cinéma
select areaId from prod_area where areaId='cinéma'
restype is CS_CMD_DONE
But I didn't get anything in the result set. I tried
to use the above to invoke a STP, and passed a string
in UTF8 as parameter, I got the same result: the
database can not find the text string.
I wrote a sql script with the above sql select
statement. Then used it as an input file to isql (
with the option "-Jutf8") and I got the expected
results back.
What did I do wrong in the above perl script? I am
using perl 5.6.0, sybper 2.10.
Any help will be highly appreciated.
Thanks,
-Gary
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
|