Maximum Length of any Field

Peter De Berdt peter.de.berdt at pandora.be
Wed Nov 12 16:15:28 CST 2003


>on 11/12/03 3:33 PM, Peter De Berdt at peter.de.berdt at pandora.be wrote:
>
>>>>  Once again. Right now Valentina do NOT provide function that all in SQL
>>>>  query define max length of column.
>>>>
>>>  As as far as I know any other DB also do not do this.
>>
>>
>>  Using your advice, I obtained what I wanted by creating a new
>>  ULongField for every field that is used in lists and attached a
>>  BaseObject method to it that holds the length of the field.
>>
>>  myLenghtfield=new VULong("myLengthField")
>>  myLengthfield.setmethod("LENGTH(myField)")
>>
>>  I then queried the DB using:
>>  "SELECT myField FROM myTable ORDER BY myLengthField DESC"
>>  The first record reflects the longest string, of which I then take
>>  the stringwidth. And without too much speed loss, even when searching
>>  60,000 records.
>
>Peter,
>
>I am glad that it works for you now,
>But I DO NOT like this way.
>
>IT IS bad idea to analyze all records of table to find the longest!
>What if table will become millions of records?
>
>Exists other more effective ways:
>
>1) why you do not want use simply VString.maxLength property ???

Because this does not reflect the actual maximum length of the 
contents. As I said, I'm migrating an Interbase db -> Valentina. I 
respect the field definitions used in Interbase, so if the source DB 
has a field "CompanyName CHAR(255)", I have a Vvarchar Field with a 
MaxLength of 255. However, the record with the longest CompanyName is 
"Just An Imaginary Company", 25 characters long and I want the 
stringwidth of this company, not the stringwidth of 255 characters.


>2) even if you want use longest length of EXISTED records,
>You can do this next:
>
>* keep somewhere CURRENT maxLength parameter for each field.
>* when you will add record, check if it add value longer, if yes, then
>update your maxLength param.
>* the same on deletion of record.
>
>This will be much more effective of your way.

Great idea! I will create a BaseObject containing the MaxLength of 
the fields. This value will never change, as the application I'm 
developing is only used to consult data from their old application 
(from our competitor which locks the application if support invoice 
isn't paid).

-- 

Best regards,

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


More information about the Valentina mailing list