开发者

Distinguish Sybase Exception types

I need to distinguish between sybase exception types based on range of error codes .

Basically I need to distinguish between sybase system related exceptions and data exceptions .

开发者_开发问答I have c# code to handle sybase database exception .

We get error codes in exception but I don't know the range which defines that the error code is sybase system exception and not data exception .

I need to handle both this exceptions in different way .

Can some one please help on this .

Copying the code below .

using System.Data.Common;

int Range1 = 0;
int Range2 = 2000;
try
{
   // Sybase data base operation 
}
catch (DbException e)
            {
  // Sybase system exception like database space not availabe , Time out error 
                if(e.ErrorCode > Range1  && e.ErrorCode< Range2)
                {
                    // This is system excpetion so dump the data to be reprocessed after database is up . 
                }
                // Excpetions like referential integrity violation , value is more than max length 
                else
                {
                    // This is data releted exception so Don't process this data again as the data itself is wrong 
                }
}


Since Sybase uses error numbers less than 2000, we chose to use numbers larger than 3000. You can control the returned error code by using the raiserror function. Yes that is not a misspelling.

Note: Sybase with many of its functions, tried to save keystrokes by eliminating duplicate characters. In this case Sybase did not allow double "e"s but left the double "r"s in. Oh well.

Good SQL, good night.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜