Maximum Length of any Field

Ruslan Zasukhin sunshine at public.kherson.ua
Wed Nov 12 13:19:58 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.

In any case your function is not right!

MAX -- must be used with GROUP BY only.

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.

------------
We use the next constants for fields

// For bool this is: "unknown" "true", "false", "yes", "no", "on", "off",
"1", "0" 
const ulong kBoolStrMaxLen = 7;

// this is 255, i.e. 3 chars
const ulong kUCharStrMaxLen = 3;

// this is -32768, i.e. 6 chars
const ulong kShortStrMaxLen = 6;

// this is "65535", i.e. 5 chars
const ulong kUShortStrMaxLen = 5;

// this is -2147483647, i.e. 11 chars
const ulong kLongStrMaxLen = 11;

// this is "4294967295", i.e. 10 chars
const ulong kULongStrMaxLen = 11;

// this is -9223372036854775807, i.e. 20 chars
const ulong kLLongStrMaxLen = 20;

// this is ???, i.e. 20 chars
const ulong kULLongStrMaxLen = 20;

// this is ???, i.e. 20 chars
const ulong kFloatStrMaxLen = 20;

// this is ???, i.e. 40 chars
const ulong kDoubleStrMaxLen = 40;

// the len of date in dd.mm.yyyy format
const ulong kDateStrMaxLength = 11;

// the len of time in hh.mm.ss.nnn format (n - ms)
const ulong kTimeStrMaxLength = 13;

// the len of date-time in dd.mm.yyyy hh.mm.ss.nnn format (n - ms)
const ulong kDateTimeStrMaxLength = 24;


-----------------
For string fields you need ask it for MaxLength


-- 
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