anusha(salesforce developer)

SOQL &SOSL

  1. Insert
  2. Update
  3. Delete
  4. Undelete
  5. Upsert (Combination of insert and update)
  6. Merge (Combination of update and delete)
  1. Number of DML statements per transaction: 150 (as a whole including insert, update, delete and undelete)
  2. Number of rows processed per DML stmt: 10000
insert/updateDatabase.insert/Database.update
Assume that you are inserting 100 records. If any one of the record fail due to error then entire operation will fail. None of the records will be saved into the database.Assume that you are inserting 100 records. If any one of the record fail due to error then it will perform partial operation (valid records will be inserted/updated) if we useDatabase.insert(list,false)/ Database.update(list,false).
with insert/update if we use try-catch then we can capture only one error which will cause to stop the operation.with Database.insert/Database.update we can capture all the errors by saving result in Database.saveResult[].

Q. What is a SOQL (SALESFORCE OBJECT QUERY LANGUAGE)?

Answer:
The Salesforce Object Query Language (SOQL) to construct simple but powerful query strings to select records from salesforce objects. Similar to the SELECT command in Structured Query Language (SQL), SOQL allows you to specify the source object (such as Account), a list of fields to retrieve, and conditions for selecting rows in the source object.
       For example, the following SOQL query returns the value of the Id and Name field for all Account records if the value of Name is Sandy:
 SELECT Id, Name FROM Account WHERE Name = 'Sandy'

Queues will store in Group object. To query for MyQueue from the database using SOQL, we should use the following syntax -
1
Group grp = [select Id, Name from Group where Name = 'MyQueue' and Type = 'Queue' Limit 1];

Q. What is a SOSL (SALESFORCE OBJECT SEARCH LANGUAGE)?

Answer: 
Salesforce Object Search Language (SOSL) to construct simple but powerful text searches for the Search() call. Unlike SOQL, which can only query one object at a time, SOSL allows you to efficiently search text, email, and phone fields for multiple objects at a time with a single query.

Q.When does we use SOQL and SOSL in SALESFORCE?

Answer:
SOQL:
1. You know in which objects or fields the data resides.
2. You want to retrieve data from a single object or from multiple objects that are related to one another.
3. You want to retrieve data from number, date, or checkbox fields.
4. You want to count the number of records that meet specified criteria.
5. You want to sort results as part of the query.
SOSL:
1. You don't know in which object or field the data resides and you want to find it in the most efficient way possible.
2. You want to retrieve multiple objects and fields efficiently, and the objects may or may not be related to one another.
3. You want to retrieve data for a particular division in an organization using the divisions feature, and you want to find it in the most efficient way possible.
BOTH SOQL OR SOSL:
1. Both SOSL and SOQL WHERE filters can specify text to look for. When a given search can use either language, SOSL is generally faster than SOQL if the search expression uses leading wildcards or a CONTAINS term.
2. In some cases, when multiple WHERE filters are being used in SOQL, indexes cannot be used even though the fields in the WHERE clause may be indexed. In this situation, decompose the single query into multiple queries each with one WHERE filter and then combine the results.
3. Executing a query with a null in a WHERE filter makes it impossible to use indexing. Such queries must scan the entire database to find appropriate records. Design the data model not to rely on nulls as valid field values.
4. If dynamic values are being used for the WHERE field and null values can be passed in, don’t let the query run to determine there are no records; instead check for the nulls and avoid the query if necessary.
Question: SALESFORCE SOQL AND SOSL GOVERNOR LIMITS?Soql_And_Sosl_Governor_Limits
Answer:
Description
Limits
Total number of SOQL queries issued
100
Total number of SOQL queries issued for Batch Apex and future methods
200
Total number of records retrieved by SOQL queries
50,000
Total number of records retrieved by Database.getQueryLocator
10,000
Total number of SOSL queries issued
20
Total number of records retrieved by a single SOSL query
200
Question: What are the diff bt SOQL and SOSL in SALESFORCE?
Answer: 
SOQL
SOSL
It’s a Salesforce Object Query Language.
It’s a Salesforce Object Search Language.
Search in Single Object.
Search in Entire Organization or Data base.
Returns Records.
Returns Fields.
It can use in Triggers.
It can use in Triggers. Changed

No comments:

Post a Comment