You need to sign in to do that
Don't have an account?
shiv
How to put an Id into a query manually
Hello, a basic question, how to put an Object Id manually into a select query
My problem is the following code shows error
System.QueryException: unexpected token: MqXA9AAN
Class.testApex.getA: line 4, column 19
External entry point
Class.testApex.getA: line 4, column 19
External entry point
public class testApex {
public Account getA(){
Id id='0018000000MqXA9AAN';
Account a=Database.query('select id,name from Account where id='+id);
return a;
}
}
public Account getA(){
Id id='0018000000MqXA9AAN';
Account a=Database.query('select id,name from Account where id='+id);
return a;
}
}
I also tried to put '... where id=:id') .. It showed
System.QueryException: Binding not supported with dynamic SOQL
Class.testApex.getA: line 4, column 19
External entry point
Class.testApex.getA: line 4, column 19
External entry point
Please provide me a solution
or, build you full query string before submitting the query:
System.QueryException: unexpected token: MqXA9AAN
select foo__c from bar__c where id='someId'
generate your string like this: String qs='select id,name from Account where id=\''+id+'\' LIMIT 1';