Problem with RAISERROR and ODBC

  • Dear,

    I have a problem with the RAISERROR severity level through ODBC API.

    I have a stored procedure : CREATE PROC MyProc AS RAISERROR 'ERROR', 16, 1

    I call this procedure with SQLExecDirect(hstmt, "EXEC MyProc", SQL_NTS)

    It returns SQL_SUCCESS_WITH_INFO though the MSDN states that it should return SQL_ERROR if the severity is greater than 10.

    I have the same behaviour on both SQL server 2000 and SQL server 2005.

    Can someone tell me how to have SQLExecDirect return SQL_ERROR ?

    Thank you

    Patrick

    Patrick Duflot

  • Have you checked what SQLGetDiagRec (or SQLGetDiagField with SQL_DIAG_SS_SEVERITY) returns for you?

  • Thanks for yout reply.

    Yes, SQLGetDiagRec gives me the right error message. I cannot make the difference between an error and a warning with this information.

    On the other hand, SQLGetDiagField with SQL_DIAG_SS_SEVERITY works well and solved my problem. Thank you.

    NB : I also noticed that when I use RAISERROR in a batch (I mean not in a stored procedure), SQLExecDirect correctly return SQL_ERROR if the severity is greater than 10. Weird... but as it works for me with SQLGetDiadField, I won't investigate further.

    Patrick

    Patrick Duflot

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply