Problem on charlength ora12899

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
djk_greensystems
Posts: 2
Joined: Tue 15 Jan 2013 09:47

Problem on charlength ora12899

Post by djk_greensystems » Tue 15 Jan 2013 09:56

Database converted to Unicode; Oracle 11.
Table-definitions changed from 10 byte to 10 char.

When adding fields in fieldsedit --> size is 40 (independent of orasession.options.charlength or orasession.options.unicode).

This is followed by a problem on updates, when filling in a string > 10 chars:

in 10 byte-situation: length of string is automically truncated to 10 characters max.
In new situation is this not the case anymore...

--> ora error message 12899: Value too large for column (actuel 20, maximum 10).

How to deal with this?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Problem on charlength ora12899

Post by AlexP » Tue 15 Jan 2013 13:27

Hello,

To solve the problem, you should enable the UseUnicode option. In this case, the Delphi field length will be equal to the field length set when creating a table.
This is due to that Oracle returns field length as bytes, and the length will be 40 for the UTF8 encoding, since the maximum character length in this case is 4 bytes. When enabling the UseUnicode option, we know that the Unicode encoding will be used, and we calculate the string length correctly by ourselves. If this option is enabled, we remain the field length in bytes

djk_greensystems
Posts: 2
Joined: Tue 15 Jan 2013 09:47

Re: Problem on charlength ora12899

Post by djk_greensystems » Sat 26 Jan 2013 21:20

With setting above, I run into the following bug:

Local Oracle XE; Unicode works fine, both in direct mode and via TNS.

In Production: Oracle Standard
Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
the following problem:
via TNS --> OK
Direct: Ora-error 12899. Also visible in Fields-editor in Delphi.
Example varchar2(100 char) = 400 Byte
Direct mode --> Size = 400
Via TNS --> Size = 100

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Problem on charlength ora12899

Post by AlexP » Mon 28 Jan 2013 10:01

Hello,

Finding of field length in both OCI and Direct modes depends on the UseUnicode option. If this option is set to False, the real field length in bytes (100 char= 400 bytes) will be taken into account, if the option value is True - field length in char. Please make sure this option is set to True when working in the Direct mode.

Post Reply