function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kathyanikathyani 

FieldType is displayed as double instead of an Integer

Hi,

I created a table in SF and for one of the fields I chose Number as data type. When I view the table in eclipse the field is displaying double as its data type. I do not want that field to be declared as double just need to be an Integer.

How can I solve this, quick help would be appreciated.


kathyani
JimRaeJimRae
When you created the number field, how many decimal places did you allow?  Should be 0 for an Integer.
kathyanikathyani
Yes I have 0 in Decimal Places and Length - 18.
kathyanikathyani
It is still displayed as a double with Decimal Places equal to zero.
kevinbnpowerkevinbnpower
Max 32-bit integer value is 2,147,483,647.

When you declared your 'Number' to be 18 digits long, the API automatically created a double for you since an integer cannot contain 18 digits.


kathyanikathyani
I changed that number and refreshed the table. Still displays as double.
JimRaeJimRae
Looks like it will always be a double. I even tried making a Number(5,0) and type still indicates a double.  THe apex documentation does make reference to implicit conversion from lower to higher numeric types, you might want to look at that.
kevinbnpowerkevinbnpower
You'd need to delete the entire field and recreate it from scratch.  Deleting the field length and recreating only resets the property of the Double data-type object (I assume).

Is there any reason you can't work with a double in this case? It has 99.9% of the same properties as an integer, the only issue is if you're concerned about storage space...


JimRaeJimRae
I created a new custom object from scratch with 2 number custom fields, one a 10,0 and the other a 5,0 and both were viewed by Eclipse as Doubles.  I think you are right, there should'nt be a problem with them being doubles, unless the concern is that too large a non decimal value is put into the field, which could be controlled with validation rules if needed.
kevinbnpowerkevinbnpower
Well sonuvagun, I never would've noticed that!  Apparently since they're implicitly convertible, SF figured nobody would notice, I certainly didn't!


kathyanikathyani
In my Value object code, I am creating a variable corresponding to this field from SF. I had to declare that as double when it could have been just an integer(number field) because it will never need a decimal.


totalNum = m.TotalNum__c;   

totalNum is a variable declared in my value object that corresponds to TotalNum__c in SF.
kevinbnpowerkevinbnpower
You SHOULD be able to declare totalNum as an integer, at least I've never had a problem with that, they're implicitly (automatically) converted.
kathyanikathyani
I am creating a value object in my code that has a field variable corresponding to this field in SF.

Example:

totalMail = m.TotalMail__c;   

where totalMail is the field defined in my value object that corresponds to TotalMail__c in SF. I had to declare totalMail as double when it could have just been an Integer. There will never be a decimal required in totalMail so I do not see a point as to why it has to be a double.
kathyanikathyani
How can we assign a double to an Integer? Did you mean type casting
kevinbnpowerkevinbnpower
It's an odd behavior, can't figure out why it does that.  At any rate, if you REALLY want to use integer values, first assign it to a double, and then explicitly convert it:

Code:
integer x;
double y;

y = [SELECT myNumberField__c from myObject__c LIMIT 1].myNumberField__c;
x = y.intValue();

 



Message Edited by kevinbnpower on 12-11-2008 02:15 PM
kevinbnpowerkevinbnpower
Yes, see above :manhappy:
kathyanikathyani
Thanks for the help. I might leave it as double if its OK or will use the conversion, thanks again.