on ‎2011 Sep 03 1:21 AM
How to log all database server errors like primary key violation error, column not found...into separate table on the same database with error message, user id, date and time. Is there any system event to log the errors?
Request clarification before answering.
I don't have a real answer, just a few hints...
What is the goal of this logging - should it also log errors in ad-hoc queries from DBISQL and the like?
(Personally, I often need a few attempts to get ad-hoc queries working - wrong syntax, typos in column names etc. These lead to error messages, too - but I wouldn't expect any worth in logging these "query attempts" - besides showing me what I already know:))
I'm not aware of a general-error-logging facility. I guess usually each application will use its own scheme of logging. E.g. moszt (or all?) of the builtin SQL Anywhere's utilities have the -o option to log their output (including success and error messages) to a file.
The default error handling is to reject the failing statement and notify the calling environment with an according error code and message. When using stored procedures, triggers or batches, you can define error handlers that do what you want, including logging these errors in a user-table (which might need a separate transaction when the original transaction is rolled back). However, AFAIK, there's no way to specify a general event handler.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.