Monday, 28 March 2016

mutually exclusive Actions? and Why?? With Example

 What are the mutually exclusive Actions? and Why?? With Example

SQL and Call Section are mutually exclusive to avoid the Data Conflicts and Deadlocks.
Assume Call Section and SQL Actions are allowed in one Step.
Assume an Update SQL is there in one Step which updates ABC Table. So curser will be opened on ABC Table.
And Assume a Call Section is there in the same Step which calls the other Section which is having another SQL on the same ABC Table.
As the cursor is already opened, when it tries to execute 2nd SQL, Deadlocks and data conflicts will arise.
So to avoid these situations, Call Section is not allowed when there is an SQL Action in a Step and vice versa.
Sample Program:
Assume Call Section and SQL Actions are allowed in one Step.
Include Update SQL in one Step and from the same Step call the other Section which is having Delete SQL on the same table.
Ex:
Main Section
Step1
SQL
UPDATE ABC SET SALARY = SALARY + 1000 WHERE EMPLID = ‘XYZ’
CallSection
Call the Section1
Section1
Step1
SQL
DELETE FROM ABC WHERE EMPLID = ‘XYZ’
In Main Section – Step1 – SQL Action – Salary will be update for XYZ employee and it will not Commit. Then it calls the Section1.
In Section1 – Step1 – SQL Action – It deletes XYZ employee and as there are no other Actions it will try to Commit. As there is an uncommitted SQL, conflict will occur.
Since Call Section and SQL are Mutually Exclusive we have to write the same code in other way.
Main Section
Step1
SQL
UPDATE ABC SET SALARY = SALARY + 1000 WHERE EMPLID = ‘XYZ’
Step2
SQL
DELETE FROM ABC WHERE EMPLID = ‘XYZ’
In Main Section – Step1 – SQL Action – Salary will be update for XYZ employee. Since there are no other Actions, while coming out from Step it issues the Commit.
In Main Section – Step2 – SQL Action – It deletes XYZ employee Row and since there are no other Actions it issues the Commit.
Since there are 2 Step Level Commits there will not be any chances to exist Deadlocks.

Actions in Application Engine

  What’s the Sequence of execution?




No comments:

Post a Comment