오라클과 같은 기능을 하는 구문이다.
begin try
begin tran
--declare @arg_id int
if not exists(select * from examinee where e_idx = 3)
begin
insert into examinee(p_no,e_regday,e_id,e_category,e_subject,e_exception) values ('1','e','qwe',3,4,'q')
end
else
begin
update examinee_20121026 set e_id='qweqweqw'
end
commit
tran;
end try
begin catch
rollback tran
end
catch;
한줄로
sql = "begin try begin tran if not exists(select top 1 * from grpRank where rankIDX = '"& idx &"' and rankName = '"& rank &"') begin insert into grpRank(rankName,rankLevel) values('"& rank &"','"& level &"')) end else begin update grpRank set rankName = '"& rank &"', rankLevel = '"& level &"' where rankIDX = '"& idx &"' end commit tran; end try begin catch rollback tran end catch;"