Lew Schwartz wrote:
Vince:
I think you meant to suggest I look at len(alltrim(str(1))), no?
OK, in an attempt to rectum-fy my first brain-fart, I did a little more
experimenting, took your original query, and broke it into bits, plus
the original expression, like so:
select alltrim(str(nMonth)), alltrim(str(nYear)),
alltrim(str(nMonth))+"/"+alltrim(str(nYear)) FROM mycrap
The queries gets the VALUES you would expect, but the DISPLAY STRUCT
shows this:
Field Name Type Width
EXP_1 Character 10
EXP_2 Character 10
EXP_3 Character 21
Going back to my brainfart answer, we see that Str(nInteger) without the
qualifying length parameters results in a default len of 10:
? Len(str(1)) && 10
My supposition is that the query *thinks* it is reserving room for the
longest possible result. ie, it "knows" that Alltrim() could result in
a varying length, so ignores that and concentrates on Str(). It "knows"
that the longest possible result for a Str() with no parms is 10, so it
reserves 10 chars. Of course, in this case, it is flat out wrong,
because your numeric is only 4 digits, so could never get larger than
that. But, I bet that this is what is going on:
"A Str() operation, with no length parms, on a numeric field COULD
result in up to 10 chars, so I need to reserve that."
Instead of:
"A Str() operation, with no length parms, on a numeric field COULD
result in up to Max(Len(Field), 10) chars, so I need to reserve that."
That's my guess. I feel I have redeemed myself, and am now gathering my
tattered dignity around myself, and storming off in a huff towards the
beckoning weekend!
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.