How to detect runtime error in stored procedure invoked via SQLExecute or SQLExecDirect?



What is the most reliable way of determining whether a stored procedure
invoked via SQLExecute or SQLExecDirect encountered an error? I was assuming
that if the stored procedure fails (e.g. executes RAISERROR with severity 16
or higher, attempts to invoke bad dynamic SQL via EXEC, like EXEC("INSERT
INTO NADA BLAH-BLAH", etc), the SQLExecute and SQLExecDirect should return
SQL_ERROR or some other failure code. I think this is what SQL Server BOL
and MSDN documentation say, but apparently it returns SQL_SUCCESS_WITH_INFO.
Now, how can a program distinguish between a real error and other conditions
resulting in SQL_SUCCESS_WITH_INFO, such as encountering a PRINT statement
in the stored procedure? I guess for SQL Server, I can check the severity
attribute of the error (SQL_DIAG_SS_SEVERITY), but this attribute is SQL
Server-specific, and I need to make it generic, so that it works with other
drivers, like Oracle, Teradata, etc. Any ideas? Thanks.


.



Relevant Pages

  • SQLExecute return code for stored procedure.
    ... For SQL Server 2000, if the stored procedure threw an error and there ... SQLExecute was SQL_SUCCESS_WITH_INFO. ... as INSERT INTO tbl VALUES ...
    (microsoft.public.sqlserver.odbc)
  • ODBC, SQL Server, Frustration
    ... We have three SQL Server boxes, one for development, one for QA ... There are two DBs there and it hangs on ... I have done an ODBC trace and it stops at SQLExecute(). ... The ODBC trace showed the prepare and hung on the execute. ...
    (microsoft.public.data.odbc)