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
jtjaardjtjaard 

Help with Apex SOQL query

Hi,
 
I was just wondering why the following code might not work? I'm working through eclipse; which isn't reporting an error, but when I check my account it hasn't been uploaded. When I remove the offending code everything compiles fine and I can see it in my force account.
 
Code:
[Select l.Boat__c, l.List_Price__c, l.Listing_Type__c, l.Name, l.RecordTypeId from Listing_Details__c l where l.boat__c =:myBoat AND l.RecordTypeId = 'foo'].List_Price__c);

 
myBoat is a string that holds the id.
 
Thanks for any help.
jtjaardjtjaard
hrm...to clarify, I guess I'm wondering why something like
 
Code:
myBoatInfo = [Select l.Boat__c, l.List_Price__c, l.Listing_Type__c, l.Name, l.RecordTypeId from Listing_Details__c l where l.RecordTypeId = '01230000000DFSUAA2' and (l.Boat__c = :'a0060000004dBi5AAE')];

 why is this valid, but if I make 'a0060000004dBi5AAE' into a variable, it is now considered invalid?
Prior to this line of code, I'm filtering out null values. so what's the deal?
mahimahi
Try after removing last 3 characters..remove AAE from a0060000004dBi5AAE.
jtjaardjtjaard

Perhaps I was unclear?

The problem isn't with the value. if I hard code a value like 'a0060000004dBi5AAE' everything is fine, but if I use a variable that contains the exact same value, the soql query in my apex code fails. I don't understand why this would be an issue though.

abhi_developerabhi_developer

Hey hi,

Dont know much about it but here we are trying to match a 'string' with custom object's field which is an sobject.

wot say..??

-Abhishek Singh

 

Sameer PrasonnSameer Prasonn
Hello,

Here is the solution for the problem jtjaard,

use following code-snippit before the query and everything run flawlessly.

Id i = Id.valueOf(myBoat);
Now change the query to 
[Select l.Boat__c, l.List_Price__c, l.Listing_Type__c, l.Name, l.RecordTypeId from Listing_Details__c l where l.boat__c =:i AND l.RecordTypeId = 'foo'].List_Price__c);
and you are done!!!!

make sense???