>Dimitry,
>
>Run the code from message#
01684073. Watch your screen. Your REPLICATE(' ',10-LEN(ALLTRIM(REFERENCE))) is like REPLICATE(' ',10-LEN(REFERENCE)) for the
determination of field length. This internally runs BEFORE filling the fields.
>
>To make at as clear as possible how SELECT SQL works
>1. It does a blind run to figure out field types and length. This run is not visible and gives no record in return. This run ignores ALLTRIM() So
SELECT REPLICATE(' ',10-LEN(ALLTRIM(REFERENCE))) AS cField FROM .. is executed like
SELECT REPLICATE(' ',10-LEN(REFERENCE)) AS cField FROM .. 10-LEN(REFERENCE) is like 10-15; equals -5
>2. It runs to fill the result records, here the ALLTRIM() will be respected.
>So your code errors out on point 1.
>
>
IOW. It does not matter how many signs you have in any record in the field REFERENCE. As long as the field length itself is greater then 10, your code must fail.>
>Just an other example
>
>CREA CURSOR mycur (i1 I, c1 c(10))
>INSERT INTO mycur VALUES (0,'')
>INSERT INTO mycur VALUES (0,'c')
>INSERT INTO mycur VALUES (0,'cc')
>SELE ALLTRIM(c1) AS c1 FROM mycur INTO CURSOR cmycur
>?LEN(cmycur.c1)
>
>
>Why do you think cmycur.c1 has length 10? Because of the blind run.
Lutz,
Your point about SQL Select doing a "blind" run before actually getting the data explains why I am having a problem with this case. Thank you very much for illustrating how it works.
To resolve the issue, for now, I changed the length of the field back to 10.
Again, thank you for your help!
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham