Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Column.Size with unicode-fields

6 posts in Delphi Last posting was on 2012-01-27 07:10:14.0Z
Markus Terbrack Posted on 2012-01-23 15:09:06.0Z
From: "Markus Terbrack" <terbrack@advantex.de>
Newsgroups: Advantage.Delphi
Subject: Column.Size with unicode-fields
Date: Mon, 23 Jan 2012 16:09:06 +0100
Lines: 1
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8117.416
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8117.416
NNTP-Posting-Host: 85.8.92.125
Message-ID: <4f1d77b8$1@solutions.advantagedatabase.com>
X-Trace: 23 Jan 2012 07:07:36 -0700, 85.8.92.125
Path: solutions.advantagedatabase.com
Xref: solutions.advantagedatabase.com Advantage.Delphi:25629
Article PK: 1109208

Hi NG,

we are using NCHAR-fields and we have got the problem that in our delphi app
the columns are twice as big as they should be. I belevie the problem is
this:

SELECT left('0123456789',5) ExA, left(CONVERT('0123456789',SQL_WCHAR),5) ExB
FROM System.IOTA

The column size of ExA is 5 as i supposed. But the column size of ExB is 10
instead of 5. Even though only 5 signs are shown. Through that the column
sizes in delphi is broader as i has to be.
We are using the ads version 10.10.0.25 and 10.10.0.31.

Is this a bug and the column size in ExB should be 5 as in ExA or am i
wrong?

Kind regards
Markus


Jed Thomet Posted on 2012-01-23 16:11:05.0Z
Date: Mon, 23 Jan 2012 16:11:05 +0000 (UTC)
Message-ID: <49739e7dab93e8cea7c611fe1977@devzone.advantagedatabase.com>
From: Jed Thomet <jedt_no_unrequested_emails_please@ianywhere.com>
Subject: Re: Column.Size with unicode-fields
Newsgroups: Advantage.Delphi
References: <4f1d77b8$1@solutions.advantagedatabase.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=iso-8859-1; format=flowed
X-Newsreader: JetBrains Omea Reader 1098.1
NNTP-Posting-Host: 10.6.199.119
X-Trace: 23 Jan 2012 08:09:34 -0700, 10.6.199.119
Lines: 30
Path: solutions.advantagedatabase.com
Xref: solutions.advantagedatabase.com Advantage.Delphi:25630
Article PK: 1109209

Hello Markus,

At first glance, this does appear to be a bug. I will investigate some more
and let you know my findings..

Jed Thomet
Advantage R&D

> Hi NG,
>
> we are using NCHAR-fields and we have got the problem that in our
> delphi app the columns are twice as big as they should be. I belevie
> the problem is this:
>
> SELECT left('0123456789',5) ExA,
> left(CONVERT('0123456789',SQL_WCHAR),5) ExB FROM System.IOTA
>
> The column size of ExA is 5 as i supposed. But the column size of ExB
> is 10
> instead of 5. Even though only 5 signs are shown. Through that the
> column
> sizes in delphi is broader as i has to be.
> We are using the ads version 10.10.0.25 and 10.10.0.31.
> Is this a bug and the column size in ExB should be 5 as in ExA or am i
> wrong?
>
> Kind regards
> Markus


Alex Wong Posted on 2012-01-23 16:43:32.0Z
Date: Mon, 23 Jan 2012 16:43:32 +0000 (UTC)
Message-ID: <9d18799594f08cea7ca9aaa2175@devzone.advantagedatabase.com>
From: Alex Wong <someone@sybase.com>
Subject: Re: Column.Size with unicode-fields
Newsgroups: Advantage.Delphi
References: <4f1d77b8$1@solutions.advantagedatabase.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=iso-8859-1; format=flowed
X-Newsreader: JetBrains Omea Reader 1098.1
NNTP-Posting-Host: 10.6.193.123
X-Trace: 23 Jan 2012 08:42:01 -0700, 10.6.193.123
Lines: 33
Path: solutions.advantagedatabase.com
Xref: solutions.advantagedatabase.com Advantage.Delphi:25631
Article PK: 1109210

Hi Markus,

This is by design. The LEFT(), RIGHT() and SUBSTRING() scalars on Unicode
column assumes the size specification is the number of code points. Since
a single Unicode code point may take up to two UTF16 chars, it doubles the
size of the result.

--
Alex

> Hi NG,
>
> we are using NCHAR-fields and we have got the problem that in our
> delphi app the columns are twice as big as they should be. I belevie
> the problem is this:
>
> SELECT left('0123456789',5) ExA,
> left(CONVERT('0123456789',SQL_WCHAR),5) ExB FROM System.IOTA
>
> The column size of ExA is 5 as i supposed. But the column size of ExB
> is 10
> instead of 5. Even though only 5 signs are shown. Through that the
> column
> sizes in delphi is broader as i has to be.
> We are using the ads version 10.10.0.25 and 10.10.0.31.
> Is this a bug and the column size in ExB should be 5 as in ExA or am i
> wrong?
>
> Kind regards
> Markus


Markus Terbrack Posted on 2012-01-24 17:08:42.0Z
From: "Markus Terbrack" <terbrack@advantex.de>
Newsgroups: Advantage.Delphi
References: <4f1d77b8$1@solutions.advantagedatabase.com> <9d18799594f08cea7ca9aaa2175@devzone.advantagedatabase.com>
In-Reply-To: <9d18799594f08cea7ca9aaa2175@devzone.advantagedatabase.com>
Subject: Re: Column.Size with unicode-fields
Date: Tue, 24 Jan 2012 18:08:42 +0100
Lines: 1
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response
Content-Transfer-Encoding: 8bit
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8117.416
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8117.416
NNTP-Posting-Host: 85.8.92.125
Message-ID: <4f1ee57a$1@solutions.advantagedatabase.com>
X-Trace: 24 Jan 2012 09:08:10 -0700, 85.8.92.125
Path: solutions.advantagedatabase.com
Xref: solutions.advantagedatabase.com Advantage.Delphi:25632
Article PK: 1109211

OK. I understand that. Thanks for your reply.

But wouldn´t it be better to get the column size 5 because there are just 5
signs in that column?
In my opinion the column size should be independent from the kind of the
string.

If you run the sql-statement even the arc has more space for that column
than necessary.

Regards
Markus


"Alex Wong" <someone@sybase.com> schrieb im Newsbeitrag
news:9d18799594f08cea7ca9aaa2175@devzone.advantagedatabase.com...

> Hi Markus,
>
> This is by design. The LEFT(), RIGHT() and SUBSTRING() scalars on Unicode
> column assumes the size specification is the number of code points. Since
> a single Unicode code point may take up to two UTF16 chars, it doubles the
> size of the result.
> --
> Alex
>
>
>> Hi NG,
>>
>> we are using NCHAR-fields and we have got the problem that in our
>> delphi app the columns are twice as big as they should be. I belevie
>> the problem is this:
>>
>> SELECT left('0123456789',5) ExA,
>> left(CONVERT('0123456789',SQL_WCHAR),5) ExB FROM System.IOTA
>>
>> The column size of ExA is 5 as i supposed. But the column size of ExB
>> is 10
>> instead of 5. Even though only 5 signs are shown. Through that the
>> column
>> sizes in delphi is broader as i has to be.
>> We are using the ads version 10.10.0.25 and 10.10.0.31.
>> Is this a bug and the column size in ExB should be 5 as in ExA or am i
>> wrong?
>>
>> Kind regards
>> Markus
>
>


Alex Wong Posted on 2012-01-25 18:26:29.0Z
Date: Wed, 25 Jan 2012 18:26:29 +0000 (UTC)
Message-ID: <9d18799595668cea96b515e232d@devzone.advantagedatabase.com>
From: Alex Wong <someone@sybase.com>
Subject: Re: Column.Size with unicode-fields
Newsgroups: Advantage.Delphi
References: <4f1ee57a$1@solutions.advantagedatabase.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=iso-8859-1; format=flowed
X-Newsreader: JetBrains Omea Reader 1098.1
NNTP-Posting-Host: 10.6.193.123
X-Trace: 25 Jan 2012 10:25:53 -0700, 10.6.193.123
Lines: 65
Path: solutions.advantagedatabase.com
Xref: solutions.advantagedatabase.com Advantage.Delphi:25635
Article PK: 1109214

Hi Markus,

The query engine does not know about the digits until execution time so it
has to use the worst case scenario. The left() scalar may be taking a column
as the input so the result cannot be determined until execution time. I think
it is strange as well but that is the choice we made. If we choose to only
have 5 UTF16 chars, then we have the potential of runtime error. I will have
another look at this and see how others do this.

If you know that there will not be surrogated pairs in the result, you can
cast the result down to 5 digit.

--
Alex

> OK. I understand that. Thanks for your reply.
>
> But wouldn´t it be better to get the column size 5 because there are
> just 5
> signs in that column?
> In my opinion the column size should be independent from the kind of
> the
> string.
> If you run the sql-statement even the arc has more space for that
> column than necessary.
>
> Regards
> Markus
> "Alex Wong" <someone@sybase.com> schrieb im Newsbeitrag
> news:9d18799594f08cea7ca9aaa2175@devzone.advantagedatabase.com...
>
>> Hi Markus,
>>
>> This is by design. The LEFT(), RIGHT() and SUBSTRING() scalars on
>> Unicode
>> column assumes the size specification is the number of code points.
>> Since
>> a single Unicode code point may take up to two UTF16 chars, it
>> doubles the
>> size of the result.
>> --
>> Alex
>>> Hi NG,
>>>
>>> we are using NCHAR-fields and we have got the problem that in our
>>> delphi app the columns are twice as big as they should be. I belevie
>>> the problem is this:
>>>
>>> SELECT left('0123456789',5) ExA,
>>> left(CONVERT('0123456789',SQL_WCHAR),5) ExB FROM System.IOTA
>>> The column size of ExA is 5 as i supposed. But the column size of
>>> ExB
>>> is 10
>>> instead of 5. Even though only 5 signs are shown. Through that the
>>> column
>>> sizes in delphi is broader as i has to be.
>>> We are using the ads version 10.10.0.25 and 10.10.0.31.
>>> Is this a bug and the column size in ExB should be 5 as in ExA or am
>>> i
>>> wrong?
>>> Kind regards
>>> Markus


Markus Terbrack Posted on 2012-01-27 07:10:14.0Z
From: "Markus Terbrack" <terbrack@advantex.de>
Newsgroups: Advantage.Delphi
References: <4f1ee57a$1@solutions.advantagedatabase.com> <9d18799595668cea96b515e232d@devzone.advantagedatabase.com>
In-Reply-To: <9d18799595668cea96b515e232d@devzone.advantagedatabase.com>
Subject: Re: Column.Size with unicode-fields
Date: Fri, 27 Jan 2012 08:10:14 +0100
Lines: 1
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response
Content-Transfer-Encoding: 8bit
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8117.416
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8117.416
NNTP-Posting-Host: 85.8.92.125
Message-ID: <4f224dae$1@solutions.advantagedatabase.com>
X-Trace: 26 Jan 2012 23:09:34 -0700, 85.8.92.125
Path: solutions.advantagedatabase.com
Xref: solutions.advantagedatabase.com Advantage.Delphi:25640
Article PK: 1109219

Hi Alex,

i will have a look at this.

Thanks.
Markus

"Alex Wong" <someone@sybase.com> schrieb im Newsbeitrag
news:9d18799595668cea96b515e232d@devzone.advantagedatabase.com...

> Hi Markus,
>
> The query engine does not know about the digits until execution time so it
> has to use the worst case scenario. The left() scalar may be taking a
> column as the input so the result cannot be determined until execution
> time. I think it is strange as well but that is the choice we made. If we
> choose to only have 5 UTF16 chars, then we have the potential of runtime
> error. I will have another look at this and see how others do this.
> If you know that there will not be surrogated pairs in the result, you can
> cast the result down to 5 digit.
> --
> Alex
>
>
>> OK. I understand that. Thanks for your reply.
>>
>> But wouldn´t it be better to get the column size 5 because there are
>> just 5
>> signs in that column?
>> In my opinion the column size should be independent from the kind of
>> the
>> string.
>> If you run the sql-statement even the arc has more space for that
>> column than necessary.
>>
>> Regards
>> Markus
>> "Alex Wong" <someone@sybase.com> schrieb im Newsbeitrag
>> news:9d18799594f08cea7ca9aaa2175@devzone.advantagedatabase.com...
>>
>>> Hi Markus,
>>>
>>> This is by design. The LEFT(), RIGHT() and SUBSTRING() scalars on
>>> Unicode
>>> column assumes the size specification is the number of code points.
>>> Since
>>> a single Unicode code point may take up to two UTF16 chars, it
>>> doubles the
>>> size of the result.
>>> --
>>> Alex
>>>> Hi NG,
>>>>
>>>> we are using NCHAR-fields and we have got the problem that in our
>>>> delphi app the columns are twice as big as they should be. I belevie
>>>> the problem is this:
>>>>
>>>> SELECT left('0123456789',5) ExA,
>>>> left(CONVERT('0123456789',SQL_WCHAR),5) ExB FROM System.IOTA
>>>> The column size of ExA is 5 as i supposed. But the column size of
>>>> ExB
>>>> is 10
>>>> instead of 5. Even though only 5 signs are shown. Through that the
>>>> column
>>>> sizes in delphi is broader as i has to be.
>>>> We are using the ads version 10.10.0.25 and 10.10.0.31.
>>>> Is this a bug and the column size in ExB should be 5 as in ExA or am
>>>> i
>>>> wrong?
>>>> Kind regards
>>>> Markus
>
>