You need to sign in to do that
Don't have an account?
Sree Salesforce
dos anyone help me :- list<sobject> str=database.query('select id,name from account where name like' +'\''+st+'\'');
can you explain this.
string st='test';
list<sobject> str=database.query('select id,name from account where name like' +'\''+st+'\'');
can anyone explain clearly , How system understand these characters after like
+'\''+st+'\''
string st='test';
list<sobject> str=database.query('select id,name from account where name like' +'\''+st+'\'');
can anyone explain clearly , How system understand these characters after like
+'\''+st+'\''
+'\''+st+'\'' is just a concatenation for enclosing the sting with simple quotes in a dynamic query but it is the better way for preventing SQL injection.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_soql.htm
Without wilcards, LIKE here is equivalent to "="
and there is a special construct in apex little known: http://salesforce.stackexchange.com/questions/45788/use-a-wildcard-with-the-in-operator-in-a-soql-query