• #35477
    Salesforce | Pavan Pavan #24
    Forcetalks

    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?

     

    #35491
    Forcetalks

    Hi Pavan,

    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.

    For example:

    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.

    For example,

    String soql = ‘SELECT id, name FROM Account’;

    List<Account> accList = Database.query(soql);

    Thanks.

    #40946
    Salesforce | Aman Aman #4
    Forcetalks

    Hi,

    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.

    Thanks.

Viewing 3 posts - 1 through 3 (of 3 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2019 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?