Icon View Thread

The following is the text of the current message along with any replies.
Messages 21 to 22 of 22 total
Thread CASTing AS VARCHAR
Sun, Dec 6 2009 7:14 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< I resent being told I'm playing games.>>

Well, you are.  You refuse to tell me what it is that you think is the
problem.  IOW, you're asking for support on something and telling me to
guess what the problem is.  You really don't see the issue here ?

<< I put in a tremendous amount of effort trying to get the message across
to you on the behaviour of CAST and VARCHAR. Was that a game? >>

No, you were talking about VARCHAR.  Now you're claiming there's an issue
with CHAR types, but refusing to tell me what it is that you think is
broken.

<< I invest more time (not much this time fortunately) to produce a query
which clearly shows a difference in behaviour with CAST between VARCHAR and
CHAR which you say is the same but which the jpg I posted shows isn't only
to be told I'm playing games. Where is your evidence for this? >>

You do realize that CHAR and VARCHAR don't behave the same way at all due to
the padding, and use different default lengths when the length cannot be
calculated, don't you ?

--
Tim Young
Elevate Software
www.elevatesoft.com
Sun, Dec 6 2009 9:30 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


>You do realize that CHAR and VARCHAR don't behave the same way at all due to
>the padding, and use different default lengths when the length cannot be
>calculated, don't you ?

I wasn't, but hunting through the manual I found:

VARCHAR
A string value with a variable number of characters. The length of
the string value must always be specified. The maximum length is
512 characters. Contray to the CHARACTER type, this type does
not pad the string value with spaces.

CHAR
A string value with a fixed number of characters. If the length of
the string value is not specified, then a length of 1 is used. The
maximum length is 512 characters. When assigning a value to a
CHAR type value that is smaller in length than the specified
length, the value being assigned will be padded with spaces to
the specified length.

This latter explains the problems I illustrated with the screenshot I posted, but is slightly wrong, although not in any way that's likely to affect anyone, CHAR also uses a length of 1 even if a length of 0 is specified.

Roy Lambert
« Previous PagePage 3 of 3
Jump to Page:  1 2 3
Image