database abstraction layer and transaction in stored procedures

Post on 21-Jun-2015

169 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd

Week Target Achieved

1 30 27

2

3

Typing Speed

Jobs Applied# Company Designation Applied Date Current Status

1

2

3

Database Access Layer Module &

Database Transaction

Name@gmail.comwww.facebook.com/usernametwitter.com/usernamein.linkedin.com/in/profilenamePhonenumber

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.

mamanages database

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.

DB Transaction

• A transaction is a discrete unit of work that must be completely processed or not processed at all.

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.

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.

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.

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.

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.

Create procedure DeleteDepartment ( @DepartmentID int ) AS BEGIN TRANSACTION DELETE FROM Employees WHERE DepartmentID = @DepartmentIDIF @@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

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

Contact Us

Emarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

Start up VillageEranakulam,Kerala, India.

Email: info@baabtra.com

top related