+ Start a Discussion
Shiva RajendranShiva Rajendran 

i want to know in dept about transaction in salesforce. Help me answering the following questions

I just want a clarity on transaction in salesforce. I want answers for the following questions :
1 : Suppose i have a vf page , so according to salesforce all that's happening on this page is considered as one transaction?
2 : Unless i have loaded a new vf page ,every per transaction limit is valid for the same vf page?
3 : If till loading a new vf page is considered as transaction and the per transaction limit is valid ,then can i reload the page to avoid per transaction limitation?
4 : If a user has 2 buttons , onclick of it an soql and dml query is made , then if the user clicks the button for 150 times ,then soql exception will happen? and will all those are taken as a single transaction? I mean then all changes would get rolled back?

please do clarify me on those topics.

Thanks and Regards,
Shiva RV  
Based on my knowledge,

Visualforce is just a mark-up language where Apex is a on demand obj. oriented programming language.

Visualforce page is just there is display data that comes from apex classes, ... methods..... SOQL etc..
try to compare governer limits (Transaction limitatation) to the apex. I am not sure if Visualforce has anything to do with it though..

refreshing page is just refreshing like any other page on web browser but clicking button is calling apex controller on visualforce page and displaying applicable data. This controller can be standard controller (prewritten) or custom controller (the one we write).

Let's say you have a simple trigger which does the following,
for(Line_Item__c li : liList) {
    if (li.Units_Sold__c > 10) {
        li.Description__c = 'New description';
    // Not a good practice since governor limits might be hit.
    update li;
above code will fail
if you insert more than 150 records in Line_Item__c obejct. You are inserting 200 records via data loader is what we called transaction. And in our case that would fail.
This is the better code which performs only one dml where the one above need to perform 200 DML and we have 150 DML per transaction.
List<Line_Item__c> updatedList = new List<Line_Item__c>();

for(Line_Item__c li : liList) {
    if (li.Units_Sold__c > 10) {
        li.Description__c = 'New description';

// Once DML call for the entire list of line items
update updatedList;
In first code, if you had imported/inserted 100 records then it wouldn't have failed. Why? the limit of 150 is not hit. But however, even in 100 records you are performing DML 100 times but in second block of code even for 100 records you are performing 1 DML.

Hope it helps!