#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    3
    Rep Power
    0

    @@ERROR not working


    I wrote a store procedure like the following

    create procedure....as
    begin
    declare @e int
    select @e = 0
    begin trans
    insert.....
    if @@ERROR<>0
    begin
    @e = @@ERROR
    print "...."
    end
    if @@ERROR<>0
    begin
    @e = @@ERROR
    print "...."
    end
    if @e=0 then
    commit transaction
    else
    rollback transaction
    return 0


    it is not working....when any error (especially wrong table name)...it is raising an error and no commit or rollback getting executed in the second statement....no other setting is made apart from the above code.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    Paris Uppland
    Posts
    2,378
    Rep Power
    391
    the value of @@error is set after each statement (including if)

IMN logo majestic logo threadwatch logo seochat tools logo