Injustice - Developers Among Us (SciFiDevCon 2024)
Database Abstraction Layer and Transaction in Stored procedures
1.
2. Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
5. Database Access Layer
Module &
Database Transaction
Name
@gmail.com
www.facebook.com/userna
me
twitter.com/username
in.linkedin.com/in/profilena
me
Phonenumber
6. Data Access Layer
• A data access layer follows the idea of
"separation of concerns“.
• DAL consist of the code used to pull data from
a db.
• Its isolated from business logic layer and
presentation layer.
8. Why???? DAL
• DAL allow us to change more easily the
backend physical data storage technology
without having large impact on business logic
layer.
• Data access layers allow us to access data the
same way for different application in our
program.
9. DB Transaction
• A transaction is a discrete unit of work that
must be completely processed or not
processed at all.
10. Transaction states
• Active, the initial state; the transaction stays
in this state until while it is still executing.
• A transition is terminated only if it has either
been committed or aborted.
11. Transaction States
• Partially committed, After the final statement
has been executed
• At this point failure is still possible since
changes may have been only done in main
memory, a hardware failure could still occur.
12. Transaction States
• Committed- after successful completion.
• Once committed, the transaction can no
longer be undone by aborting it.
• Its effect could be undone only by a
compensating transaction.
13. Transaction States
• Failed, after the discovery that normal
execution can no longer proceed.
• Once a transaction can not be completed, any
changes that it made must be undone rolling
it back.
14. Transaction States
• Aborted, after the transaction has been rolled back the
database has been restored to its state prior to the start
of the transaction.
• The DBMS could either kill the transaction or restart the
transaction.
15. Create procedure DeleteDepartment ( @DepartmentID int ) AS
BEGIN TRANSACTION
DELETE FROM Employees WHERE DepartmentID = @DepartmentID
IF @@ERROR <> 0
BEGIN ROLLBACK
RAISERROR ('Error in deleting employees in DeleteDepartment.', 16, 1)
RETURN
END
DELETE FROM Departments WHERE DepartmentID =
@DepartmentID
IF @@ERROR <> 0
BEGIN ROLLBACK
RAISERROR ('Error in deleting department in DeleteDepartment.', 16, 1)
RETURN
END
COMMIT
16. If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
17. Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com