
this should be done only to active users.įor this purpose i need to construct a staging table in sql and by using this staging table in sql i need to update in salesforce. if there is any change of data in user object then i need to update in salesforce. Now by using these local user table i need to compare with data in the Salesforce user object. From 'X' db SQL server will get data into raw table and it will apply some business rules and stores the data into localtable.


I have use case that will get data from 'X' database. This condition will be executed for failed recordsįor(Database.Error objErr : sr.I want to update a Salesforce Object from a Stored Procedure inside Microsoft SQL Server. Get the invoice id of inserted Account This condition will be executed for successful records and will fetch the ids Iterate through each returned result by the method Database method to insert the records in List ObjNewInvoice.APEX_Amount_Paid_c = 1000 ĭatabase.SaveResult srList = Database.insert(InvoiceListToInsert, false) ObjNewInvoice.APEX_Customer_c = objCust.id Insert objCust // Inserting the Customer RecordsĪPEX_Invoice_c objNewInvoice = new APEX_Invoice_c() used when we will create Invoice RecordsĪPEX_Customer_c objCust = new APEX_Customer_C() Insert Customer Records First using simple DML Statement. Insert Operation Using Database methods We will be inserting the same using Database methods. Let us consider the previous scenario wherein, we have inserted new records using the DML statements. Inserting new records via database methods is also quite simple and flexible. You can get the list of success and failed records as we have seen in the example.Įxample − Database.insert(listName, False), where false indicate that partial update is not allowed. You cannot get the list of success and failed records. You can specify the Parameter in Database method as true or false, true to allow the partial update and false for not allowing the same. For example, if you have 20 records in list, then either all the records will be updated or none.

Differences between Database Methods and DML Statements DML Statements Database class methods is another way of working with DML statements which are more flexible than DML Statements like insert, update, etc.
