Maximum Length of any Field

Ruslan Zasukhin sunshine at public.kherson.ua
Wed Nov 12 15:49:47 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 ???


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.


But I still think you can simply use VString.maxLength
I have use it in VAPP,
I think Jochen have use it in Valentina Studio.


-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list