Maximum Length of any Field

Peter De Berdt peter.de.berdt at pandora.be
Wed Nov 12 12:45:55 CST 2003


>on 11/12/03 1:12 PM, Peter De Berdt at peter.de.berdt at pandora.be wrote:
>
>>  Using RB 5.2.1 and V4RB.
>>
>>  I'm trying to accomplish the following:
>>  I want to calculate the stringwidth of the longest record in some
>>  table. I can then pass back this integer value to Einhugur's DataGrid
>>  to define the columnwidth. This would allow me to create a generic
>>  class that automatically adjusts columnwidths to the longest string
>>  in the cursor.
>>
>>  However, when I try the following SQL, I don't get any results:
>>  myCursor=myDB.SQLSelect("SELECT MAX(LENGTH(myField)) FROM myTable")
>
>Hi Peter,
>
>First of all, Valentina 1.x do not support functions in SQL query directly,
>Only in BaseObject methods.


Bummer, this would mean I'd have to create an extra field with a 
BaseObject method for about every field used throughout the database 
(the user can define the columns he wants to see). But then I would 
be able to do:

"SELECT LENGTHField,Field FROM MyTable ORDER BY LENGTHField DESC" and 
take the first record to obtain the longest string in my Table? Would 
this have a serious speed impact (as the BaseObject method will 
probably execute when querying it)?

Am I right here?

>
>In any case your function is not right!
>
>MAX -- must be used with GROUP BY only.


OK, point taken.

>
>LENGTH -- returns real length of current value, but not MaxLenght of field
>as this is specified in structure Table. BTW, may be it is good idea add
>such functions.

That's what I intended to do: knowing the maximum of all the real 
length values (how long is the longest string entered by a user, so 
that even if a field can hold up to 1500 characters, if the longest 
string is only 300 chars, I need the stringwidth of 300 characters, 
not 1500).


-- 

Best regards,

Peter De Berdt
--------------
My software never has bugs, it just generates random features...


More information about the Valentina mailing list