varchar2(4000 char) on XE 11g

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: varchar2(4000 char) on XE 11g

Post by AlexP » Wed 18 Feb 2015 09:12

This problem occurs only in Delphi 5, since in this Delphi version, the TStringField size can't be over 8192.
We have added a check: now, if the size of a field is bigger than this value, then its size will be cut to the maximum possible length (8192).
This fix will be added to the next version.

P.S. However, this fix may lead to incorrect data retrieving/saving.

ths
Posts: 53
Joined: Thu 29 Dec 2011 16:18

Re: varchar2(4000 char) on XE 11g

Post by ths » Thu 19 Feb 2015 07:21

Hello Alex,

we are waiting for new version to test the changes.

However, we cannot follow your explanation.
Please, consider our arguments:
First of all, there is no problem with Oracle 11g (non-UNICODE configuration), only Oracle XE 11g (principally UNICODE) has this problem.
In Oracle maximum length of varchar2 fields in characters is 4000 characters.
At the same time maximum length in bytes is 4000 bytes.
This means that we can save in such field 4000 "normal" letters.
If we put in the field 10 letters like German letter "ü", the maximal total number of characters reduces to 3995.
This is exactely how the old version of DevArt components works with Oracle in our configuration.
We do not know exactely what is the role of the maximum length of TStringField, but this did not have such effect in the old version of DevArt components.
It looks like you multiply the length of varchar2 field by 4 for your internal purposes (buffer) that explains the maximum varchar2 length
of 2048 characters still accepted by the new version of DevArt components: 2048 * 4 = 8192.
But this actually means, that we cannot define a varchar field in Oracle table with length bigger than 2048 characters if we work with new DevArt components.
It means also that we have to do large scale changes in our application including database schema. But even so we will lose data!
If this is what you suggest, we cannot accept such approach.

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

Re: varchar2(4000 char) on XE 11g

Post by AlexP » Thu 19 Feb 2015 12:33

Since you are using a UniCode database and set the character type in a VARCHAR2 column as CHAR, then the real length of each character will be 4 bytes.
Therefore we increase the field length to a required number of bytes. In order not to increase the length, you should set the UseUnicode property to True, or the CharLength property to 1 (some problems may still occur).

ths
Posts: 53
Joined: Thu 29 Dec 2011 16:18

Re: varchar2(4000 char) on XE 11g

Post by ths » Thu 19 Feb 2015 14:04

Hello Alex,
thank you for answering.
It seems to me the statement about 4 bytes is not correct. As i already described, Oracle treat these things not so direct - any character from the "standard" part of the character set (a, b, c) is still 1 byte length and all German characters ö,ü,ä and ß take 2 byte each.
Could you explain please how the old components work then?
I do not understand why you give 4 byte per character when the maximum lenght in byte in Oracle is 4000 bytes (not 4000 characters!). You can define varchar2(4000 char) field, but you will be able to insert only 2000 "ü" characters in this field (or 4000 of "a").

I cannot set the UseUnicode property to True because of the TWideString problems.
But it could be that your advice about CharLength can help us - first test with CharLength = 2 is positive. What do you mean by pointing to some further problems using this option?

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

Re: varchar2(4000 char) on XE 11g

Post by AlexP » Thu 19 Feb 2015 16:49

Yes, the field size can't be greater than 4000 bytes, however, you will be able to insert 10 characters greater than 1 byte in a VARCHAR2(10) field. . Therefore we need to increase the field size in order for it not to be cut in Delphi.
Since on using the AL32UTF8 encoding, you can insert even 4-byte characters, then we increase the field size to 4.
If you are working with 2-byte characters only, then setting CharLength to 2 will not change the behavior. And if characters of more than 2-byte size are used, a string will be cut.

ths
Posts: 53
Joined: Thu 29 Dec 2011 16:18

Re: varchar2(4000 char) on XE 11g

Post by ths » Fri 20 Feb 2015 05:52

Hello Alex,

yes, i understand that you may need 40 bytes for a field of 10 characters, but to my mind there is no scenario when you will need more than 4000 bytes.
I still do not understand what is going to be cut and why? The size of TFieldString is
maximum 8192 bytes and Oracle cannot have varchar fields bigger than 4000 bytes - the varchar2(4000 char) field, filled with unicode characters 4 byte each, will contain 1000 characters and 4000 bytes. But this is Oracle limitation and has nothing to do with DevArt components, right?
The problem is that the componet checks field datatype (varchar2(4000 char)), multiply it by 4 and returns exception that it actually should not.
Is there something wrong in my description?
P.S. I have made a couple of tests using CharLength = 1 and found till now no problems. It seems to me the only change you need to do is to constrain the maximum size of the buffer by 4000 bytes which would be correct for Oracle varchar2 fields and will not lead to size-related exception. This would be important for cases with CharLength 0 (probaly set to 4 intern), 3 and 4. Just because the check will get 3*4000 and 4*4000 which is bigger than 8192 (although this is irrelevant). For the case CharLength = 1 and 2 it seems to me everything is okey as it is. Do you agree with this view?

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

Re: varchar2(4000 char) on XE 11g

Post by AlexP » Tue 24 Feb 2015 13:49

We will change the behavior when calculating length of such fields in the next version.

ths
Posts: 53
Joined: Thu 29 Dec 2011 16:18

Re: varchar2(4000 char) on XE 11g

Post by ths » Tue 21 Apr 2015 09:02

Hello, Support!

we have found in revision history that the
"Bug with "Invalid field size" when creating fields in Delphi 5 is fixed".
However, the installation for Delphi 5 is not available in the download list.

Vladimir

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

Re: varchar2(4000 char) on XE 11g

Post by AlexP » Tue 21 Apr 2015 11:32

We have discontinued support for Delphi 5 indeed. We can send you the last version that supported Delphi 5. For this, please send your license number to alexp*devart*com.

ths
Posts: 53
Joined: Thu 29 Dec 2011 16:18

Re: varchar2(4000 char) on XE 11g

Post by ths » Fri 24 Apr 2015 06:41

I thought such things should be announced in advance. Did i miss such announcement?
Even so, you have made an entry about bug fix for Delphi 5 version in revision history.
Why then not make this fixed version available for download?

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

Re: varchar2(4000 char) on XE 11g

Post by AlexP » Tue 28 Apr 2015 13:07

We can discontinue support for obsolete IDEs, this is mentioned in the license:

http://www.devart.com/odac/docs/#license.htm

>Devart reserves the right to cease offering and providing support for legacy IDE versions.

Post Reply