Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Get the field size
Sun, May 29 2016 6:04 AMPermanent Link

Hershcu Sorin

Hello
I need to extract the field size.
I run the loop:
for I := 0 to Query.FieldCount -1 do
  Size :=  Query.Fields.Fields[I].DisplayWidth;

if it's an integer or date field it return the actual field length
If it's a string it return 60 for all, ignoring the real field length.

How I can get the real size?
Thanks Sorin
Sun, May 29 2016 12:56 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Hershcu


Without seeing your SQL I'm guessing.  My guess would be that the fields where its returning a size of 60 are the result of some sort of calculation (eg ColumnA + ColumnB) in which case unless you specify the column size by explicitly CASTing the result (eg CAST(ColumnA + ColumnB AS VARCHAR(25)) the engine has no idea and uses its default of a column size of 60. Generally this is sort of OK because the data fits into the 60 characters. If it exceeds that I think it gets truncated at 60.

Roy Lambert
Mon, May 30 2016 4:10 AMPermanent Link

Hershcu Sorin

Yes your guess is right.
Thanks Sorin
Image