sql - Procedure stops when legacy, new error traps are next to each other -


we have bunch of old stored procedures legacy style error trapping. changed 1 other day , included newer try...catch block. stored procedure stopped after try/catch , returned though there error in legacy block.

if put a

select null 

in between 2 works fine. know why happening?

--begin new error trap-- begin try stuff... end try begin catch end catch --end new error trap--- ----------------- old school trap begin ----------------- select  @sperror = @@error ,         @sprowcount = @@rowcount set @spreturn = @spreturn + 1 if ( @sprowcount <= 0      or @sperror <> 0    )      set @spreturn = 0 - @spreturn if ( @sprowcount <= 0      or @sperror <> 0    )      return @spreturn select  @sprowcount = -1 ,         @sperror = -1 ------------------ old school error trap end ------------------ 

in try catch block, last statement doing sets row count 0. "select null" setting row count 1, since returns 1 row, no error detected.

you can fix changing logic in "old" code or setting row count variable in try/catch code. recommend remove select null, since guarantee success , may not want behavior.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -