Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2002
    Posts
    15

    Question Unanswered: Stored Procedure Error Handling

    Greetings,

    I have been writing a back-end app 99% in SQL 7 stored procedures. It is necessary to document what is going through the system in an application log table I created.

    I have been trapping SQL errors to determine if I write successful or error messages.

    Example:
    SELECT @v_sql_error = @@ERROR, @v_row_count = @@ROWCOUNT
    IF @v_sql_error <> 0
    SET @v_return_code = 999

    The issue is I have some programs that use Bulk Insert statements. Those bomb the procedure instead of setting the @@ERROR. I have tried Adding BEGIN..END to further trap it with no success.

    I could Insert a "Failed" message first and update it with success if the BULK insert works. My concern is that the processing may not continue in the calling stored procedure.

    Any help is appreciated,
    Mike

  2. #2
    Join Date
    Dec 2002
    Posts
    15

    Re: Stored Procedure Error Handling

    I ended up using xp_command to call the stored proc with upload with isql. It is a hack, but the application works very well and traps all the errors without uncontrolled exceptions.

    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •