i am coding C with using open client for database jobs on sybase and i
got some errors about charsets. My sybase server is ASE 15.02 and when
i run bcp from open client with blk_init, following errors are
followed.
Server message:
Message number: 4847, Severity 16, State 1, Line 1
Server 'SYBBLKTEST'
Message String: BCP insert operation is disabled when data size is
changing between client and server character sets. Please use BCP's -Y
option to invoke client-side conversion.
Server message:
Message number: 3621, Severity 10, State 0, Line 1
Server 'SYBBLKTEST'
Message String: Command has been aborted.
Open Client Message:
Message number: LAYER = (0) ORIGIN = (0) SEVERITY = (0) NUMBER = (0)
Message String: blk_init(): blk layer: CT library error: Failed when
CT_Lib routine ct_results() called.
ERROR: BulkCopyIn: blk_init() failed
On the other hand, I have to keep server's default character set as
iso_1. i can not change default char set. Ok. When i use -Y option in
BCP command from command line , error is gone. but i use open client
library from C and i couldnt find any parameter for define some option
like -Y for blk_init or blk_props or other functions. How can i
handle that?
regards
aykut
> On the other hand, I have to keep server's default character set as
> iso_1. i can not change default char set. Ok. When i use -Y option in
> BCP command from command line , error is gone. but i use open client
> library from C and i couldnt find any parameter for define some option
> like -Y for blk_init or blk_props or other functions. How can i
> handle that?
>
> regards
> aykut
I'm not an expert in Open Client, but my guess would be that you would
use cs_manage_convert
to convert on the client side from your multi-byte character set to
iso_1.
-bret
The Bulk-Library equivalent of bcp's -Y parameter is the "BLK_CONV"
property:
http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc32850.1500/html/comlib/X72074.htm
It essentially says that the client will perform character set
conversion instead of the server.
If you enable this property, you may also want to set
CS_NOCHARSETCNV_REQD=CS_TRUE so that
character conversion is not attempted at the server level:
http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc32840.1500/html/ctref/X21080.htm
Thanks,
Neal
I am so sorry to be late for share another solution about this
subject. Anyway, your suggestion seems the best way Neal.
The other solution that i have used;
CS_LOCALE *G_locale;
cs_locale( contextPtr, CS_SET, G_locale, CS_SYB_LANG,"us_english",
CS_NULLTERM,(CS_INT*)NULL);
cs_locale( contextPtr, CS_SET, G_locale, CS_SYB_CHARSET,"utf8",
CS_NULLTERM,(CS_INT*)NULL);
ct_con_alloc(...);
ct_con_props( connectionPtr, CS_SET, CS_LOC_PROP, G_locale,
CS_UNUSED, NULL);
...
Thanks and best regards.
Aykut
Best regards
Aykut
SybaseNeal wrote:
> Yes, if your client and server character sets match than no character
> set conversion will take place.
>
> But if your data is actually a different character set, let say sjis
> for some Japanese data, you would
> not want to set your client character set to utf8 just to get past the
> conversion restrictions. This
> could cause the data to be stored improperly.
>
> Ideally, you want your client character set to be the same character
> set as your data.