Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2006-12-15 : 07:31:03
|
| below code is working fine,while passing query correctly if i pass the value like this:exec proctest('rab44','sent','25','fff')this gets rollbacked correctly..Just i need to know where the error occured whether in first begin,end statment or the second one and then the type of error occuredcreate procedure proctest(@idno char(7),@name varchar(9),@age int,@wages decimal(15,2))as declare @err intset nocount onbegin transaction begin insert into gworker(idno,name) values(@idno,@name) set @err=@@error if @err<>0 rollback tran end begin insert into oworker(idno,age) values(@idno,@age) @err=@@error if @err<>0 rollback tran end begin insert into msalary(idno,wages) values(@idno,@wages) @err=@@error if @err<>0 rollback tran endcommit transactionend transaction |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2006-12-15 : 07:51:13
|
| create procedure ...as @err intshould becreate procedure ...as DECLARE @err int--Lumbago"Real programmers don't document, if it was hard to write it should be hard to understand" |
 |
|
|
mahesh_bote
Constraint Violating Yak Guru
298 Posts |
Posted - 2006-12-18 : 00:21:33
|
quote: Originally posted by sent_sara below code is working fine,while passing query correctly if i pass the value like this:exec proctest('rab44','sent','25','fff')this gets rollbacked correctly..Just i need to know where the error occured whether in first begin,end statment or the second one and then the type of error occuredcreate procedure proctest(@idno char(7),@name varchar(9),@age int,@wages decimal(15,2))as declare @err intset nocount onbegin transaction begin insert into gworker(idno,name) values(@idno,@name) set @err=@@error if @err<>0 rollback tran end begin insert into oworker(idno,age) values(@idno,@age) @err=@@error if @err<>0 rollback tran end begin insert into msalary(idno,wages) values(@idno,@wages) @err=@@error if @err<>0 rollback tran endcommit transactionend transaction
Just check, you were passing non numeric values to 3rd and 4th params, as they must be numeric. let us know, if u have any problem.Mahesh |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-18 : 10:16:31
|
| www.sommarskog.se/error-handling-I.htmlwww.sommarskog.se/error-handling-II.htmlMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|