May 3, 2011 at 10:32 am
I have a cursor loop, and within it I have a BEGIN TRY / END TRY with a lot of code inside, followed by BEGIN CATCH / END CATCH. I want to ignore certain error number.
I put like this:
begin catch
if error_number() = 2725 begin
continue
end
end catch
but it keeps loopimg through the same record. I need it to go to the the next one in the cursor, what should I put instead of continue? I could not find it in B.O.L.
Thanks
May 3, 2011 at 10:36 am
Assuming you do a fetch into it'll loop in the next record.
Are you sure the catch is not preventing the next fetch operation?
Or you could have more than 1 copy of the same "problem" data.
May 3, 2011 at 12:27 pm
I'd have to see more of the code to help much. Can you post the whole loop?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
May 4, 2011 at 1:26 am
Hi
First fetch the record the use continue.
like below.
begin catch
if error_number() = 2725 begin
Fetch the Record
continue
end
end catch
May 4, 2011 at 4:16 am
http://msdn.microsoft.com/en-us/library/ms179296.aspx
http://msdn.microsoft.com/en-us/library/ms175976.aspx
http://sqlblog.com/blogs/eric_johnson/archive/2010/10/12/tsql-try-catch.aspx
Regards,
Syed Jahanzaib Bin Hassan
BSCS | MCTS | MCITP | OCA | OCP | OCE | SCJP | IBMCDBA
My Blog
www.aureus-salah.com
May 4, 2011 at 5:48 am
pss.srinivasan (5/4/2011)
HiFirst fetch the record the use continue.
like below.
begin catch
if error_number() = 2725 begin
Fetch the Record
continue
end
end catch
We can't help you pinpoint the problem without seeing exactly what code you are running. So untill you post that, good luck.
May 4, 2011 at 5:51 am
Syed Jahanzaib Bin hassan (5/4/2011)
http://msdn.microsoft.com/en-us/library/ms179296.aspxhttp://msdn.microsoft.com/en-us/library/ms175976.aspx
http://sqlblog.com/blogs/eric_johnson/archive/2010/10/12/tsql-try-catch.aspx
Nice links, can you help me spot the paragraph that talks about debugging a proc that compiles, catches the error but repeats it in those links?
I don't see anything talking about that in those 3 links.
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply