Here’s the scenario:
- You load a page, which renders based on the data in the database (call these the “assumptions”)
- Someone changes the assumptions
- You submit your page
- ERROR!
The general pattern to solve this problem is this (right?):
In your save proc, inside a begin and commit transaction, you validate your assumptions first. If any of them changed, you should return a graceful error message, something like an XML list of the ID’s you had problems with, that you handle in the page rather than let it be handled by the default error handling infrastructure.
So my question is what is the best way to do that?
- Return the xml list and an error flag in out parameters that are unset and 0 if it completes correctly?
- Use an out parameter to return an error status, and the result of the proc be either the error list or the valid results of the proc?
- Something else? (I should note that raiseerror would cause the proc to be in error, and get picked up by the default error handling code)
Update: I would like to return a maniplatable list of IDs that failed (I plan to highlight those cells in the application). I could return them in CSV format in RAISEERROR, but that seems dirty.