Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select-SQL not creating big enough field for selected da
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00113618
Message ID:
00113959
Views:
30
>>I'm getting the name of the month with the following code in a select-sql from a table with totals for products shipped per day:
>>
>>select distinct val(substr(shipdate,1,2)) as month_num,cmonth(ctod(shipdate)) as month
>>
>>The field in the resulting table seems to be limited to the size of the first entry i.e. fieldsize = len(January). So all I get for the next month is Februar.
>>
>>Is there any way to stop this from happening?
>>
>>
>>TIA
>>
>>E.R. Gilmore
>
>Because you are using a function, the length of the field is determined by the first value returned by that function. Fox will use that length throughout. You'll have to pad it to a length big enough to accomodate the max length required by any expected return of the function.
>
>Steve

You are right. I just want to add that, in fact, the length is not from the first returned value. I mean: is not from the value returned for the first row in the result table. Before creating any row in the result table, VFP evaluates each field and creates the structure. This counts as an extra evaluation and it means all functions are evaluated twice for the first row (once for the structure creation and once for the first row). It is not important in this case, but it may be important when the UDF counts something.

Vlad
Previous
Reply
Map
View

Click here to load this message in the networking platform