Hi Folks - whilst building a data dictionary I need to get the length of the columns, and get.length works fine except on INTEGER types, where it returns 0.
What I really need here is to determine if the INTEGER is a bit or greater. I’ll use that info later when presenting the columns to a user and allowing him to use them in a search - so I need to know if it’s a true/false or a number for them to enter.
Is there a problem with get.length in this regard? Or is there a better way to do this?
EDIT:- I see that Servoy table view has all of these INTEGER Columns as zero there - so I guess the get.length is gathering its info from this location rather than the actual table structure.
Question now then is, why is the tableview in Servoy not showing the actual column size for these INTEGER’s? The columns in the back-end are set correctly and show the full size of the column (bits are 1, some INTEGER’s are 1 and some greater), in this instance in MySQL.
The columns appear to be correctly used in the solution but why does Servoy display them differently, and how can I interogate the column size corretly (as set in the database)?
I think integer is a fixed length type, for example in mySQL a 4 byte value between -2147483648 and 2147483647. If you specify a “length”, you are actually specifying a display width, not a constraint on the column. So a int(6) column can still store the number 2147483647. So in short I’d say, integers have not length other than a minimum and maximum value that can be stored. You can already see that in mySQL. The maximum number you can store is 2147483647. That is a 10 digit number. Following your idea of a length, this would be int(10) and you’d expect to be able to store 9999999999 as well, no? Well, you can’t.
patrick:
So in short I’d say, integers have not length other than a minimum and maximum value that can be stored. You can already see that in mySQL. The maximum number you can store is 2147483647. That is a 10 digit number. Following your idea of a length, this would be int(10) and you’d expect to be able to store 9999999999 as well, no? Well, you can’t.
Excellent feedback Patrick - thanks for taking the time to straighten me out on that.
Is there a way, in Servoy, to determine what the display width actually is as set in MySQL then?
Servoy does not seem to distinguish between a BIT and an INTEGER type at all - so if I can determine the width is 1 I can assume (in my instance) that its a Bit Column?
Kahuna:
Is there a way, in Servoy, to determine what the display width actually is as set in MySQL then?
Kahuna,
Servoy does not return the length for date or integer class columns, we always return 0.
This would not make any sense for us because the length of a columns is quite different across databases.
Even length 1 would usually mean 1 byte so allowing 256 values, not just 2.