set xact_abort on 사용시 주의점.(2)
작성자 : 단국강토
등록날짜 : 2009.01.12 09:46
제목 : set xact_abort on 사용시 주의점.(2) | |||||
<PRE style="BACKGROUND-COLOR: white">if object_id('tblx') is not null drop table tblxgoif object_id('tbly') is not null drop table tblygocreate table tblx(idx int identity (1,1), a int)gocreate table tbly(idx int identity(1,1), a int)go-- 프로시져 1 if object_id ('usp_1') is not null drop proc usp_1gocreate proc usp_1(@input int)asset xact_abort onbegin trandeclare @error int-- 2 프로시져 실행exec @error = usp_2 @inputif @error <> 0 goto 에러insert into tblx values (@input)if @input > 10 goto 에러commit tranreturn 0 에러:rollback tranreturn -1go-- 프로시져 2 if object_id('usp_2') is not null drop proc usp_2gocreate proc usp_2(@input int)asbegin tran insert into tbly values(@input)if @@error <> 0 goto 에러commit tran return 0에러: rollback tran return -1goexec usp_1 1exec usp_1 1exec usp_1 1exec usp_1 1exec usp_1 11exec usp_1 11exec usp_1 11exec usp_1 1exec usp_1 1select * from tblxselect * from tbly-- 두군데 모두 5,6,7 이 없다 잘 rollback 되었다는 것을 확인 할 수 있다. </PRE> |
"쇼핑몰·홈페이지·오픈마켓
블로그·페이스북·이메일 등의 각종 마케팅 글쓰기, 각종 광고, 영업, 판매, 제안서, 전단지 반응율 3배×10배 이상 높이는 마법의 8단계 공식" |
☞자세히보기 |
|
|