Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The number in Replicate creates a problem
Message
 
 
To
05/04/2022 08:23:29
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
01684050
Message ID:
01684069
Views:
28
>>>>Good point. I did what you suggest and the value in the column for LEN(ALLTRIM(REFERENCE)) shows the actual number of characters in the field. And yet, when I REPLICATE with the 10-.... or 15--... it does not work.
>>>>Thanks
>>>
>>>
>>>SELECT REFERENCE, Cast(REPLICATE(' ',15-LEN(ALLTRIM(REFERENCE))) + ' ' AS c(100)) as TEST FROM WO_REFER
>>>
>>
>>Strange results. When I do the CAST() as you suggested and leave the number in REPLICATE to be 15, the resulting column TEST has the correct number of the 'nbsp'. That is, if the value in the field is 'A', the value in the TEST is 14 strings of 'nbsp'
>>But if I change the 15 with 10, error "String too long to fit"
>
>Strange. Try to change c(100) to c(150), just to test. Or c(200).

I did. To no avail.

Let me show you what works:
SELECT REFERENCE, 10-LEN(ALLTRIM(REFERENCE)) AS TEST2 FROM WO_REFER
The above column TEST2 has the right number.
But if I add REPLICATE around the above, as this:
SELECT REFERENCE, REPLICATE('xyz', 10-LEN(ALLTRIM(REFERENCE))) AS TEST2 FROM WO_REFER
Error: String too long to fit.
It appears that REPLICATE is the problem. I wish there were another function that would do pretty much the same.
"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
Previous
Reply
Map
View

Click here to load this message in the networking platform