- September 20, 2018 at 5:21 am #35477Pavan #24
Differentiate between Static SOQL and Dynamic SOQL in Salesforce.
What is static soql and dynamic soql?how it was differentiated and in which scenario it will be useful? Why ‘/ ‘is used in dynamic soql is used?September 20, 2018 at 6:50 am #35491Anurag algoworks #12
Static SOQL is one which you write in square brackets. It is good to use when you didn’t have any dynamic changes in the soql query.
list<Contact> con=[Select Id, LastName from Contact]
Dynamic SOQL refers to the creation of a SOQL string at runtime with Apex code. Dynamic SOQL enables you to create more flexible applications.To create dynamic query at runtime, we use Database.query() method.
String soql = ‘SELECT id, name FROM Account’;
List<Account> accList = Database.query(soql);
Thanks.September 29, 2018 at 4:43 pm #40946Aman #4
Static SOQL is written in () array brackets. Its good to use when you did not have dynamic chnages is SOQL.
Dynamic SOQL refers to the creation of a SOQL string at run time with Apex code. Dynamic SOQL enables you to create more flexible applications. For example, you can create a search based on input from an end user or update records with varying field names.
Please Register to reply to this topic. /