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
textualtextual 

retrieve records from empty / null decimal

looks like if i set a fields value to null, then query the table for those records, they dont get returned. because a decimal thats null isnt actually null??
 
Account bad_data = [SELECT Id, Name, Latitude__c, Longitude__c, Location__latitude__s, Location__longitude__s 
                    	FROM Account 
                    	WHERE Id IN ('0018000000mZrLUAA0')][0];
system.debug(bad_data);
system.debug('bad_data.Latitude__c = null ? ' + bad_data.Latitude__c == null);
system.debug('bad_data.Longitude__c = null ? ' + bad_data.Longitude__c == null);
system.debug('bad_data.Location__latitude__s = null ? ' + bad_data.Location__latitude__s == null);
system.debug('bad_data.Location__longitude__s = null ? ' + bad_data.Location__longitude__s == null);


system.debug('bad_data.Latitude__c ? ' + String.valueOf(bad_data.Latitude__c));
system.debug('bad_data.Longitude__c ? ' + String.valueOf(bad_data.Longitude__c));
system.debug('bad_data.Location__latitude__s ? ' + String.valueOf(bad_data.Location__latitude__s));
system.debug('bad_data.Location__longitude__s ? ' + String.valueOf(bad_data.Location__longitude__s));

// get records
// are they null: nope
// well then what are they? theyre null

smh
Shashikant SharmaShashikant Sharma
Could you explain the problem more ?
textualtextual
i need help writing a query that selects records with decimal fields that are almost null. i say almost because i set them to null, yet theyre arent actually null. as a tesst, i select one of these known records and then compare the fields values. the first comparison; is this null, returns false, its not null. the second comparison converts the decimal to a string so i can see what it is. that portion returns null. :confused_face:

is its not null but when i try to output it, its says null
how am i supposed to query to target these records??

 
Crystal Rochlitz 4Crystal Rochlitz 4
I ran this code yesterday because it caught my attention. When I was messing with it today however, if you write the boolean statements like this: 
system.debug('bad_data.Latitude__c = null ? ' + (bad_data.Latitude__c == null));

with the second set of surrounding para's, you get the right results: true in all cases. Don't know if that will help or not, just something I noticed. If you have some code to share, I'm sure the community would be happy to help out.
textualtextual
im trying to retrieve these records with mixed null / empty values, so the comparison afterwards is moot if i cant pick the records with soql
 
// breaks
SELECT Id, Name, Location__latitude__s, Location__longitude__s , Latitude__c, Longitude__c
FROM Account 
WHERE location__c = null // errors because this location field is protected / hidden??

// incorrect results
SELECT Id, Name, Location__latitude__s, Location__longitude__s , Latitude__c, Longitude__c
FROM Account 
WHERE Location__latitude__s = null // doesnt retrieve records with previously nulled out values

 
Crystal Rochlitz 4Crystal Rochlitz 4
Do you have the colons after your equals signs ie.. =: null
textualtextual
no, that breaks the query