Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

I use the ODBC API to execute SQL (SQLExecDirect) and to trap errors that result from that execution (SQLGetDiagRec). Lets say I insert into a table that has a trigger and somewhere in that trigger there is an exception. Right now, SQLGetDiagRec, just returns a basic message (e.g. 'divide by zero'). It doesn't return any details about which trigger, procedure or function this error happen to occur in. In theory, SQLGetDiagField can be used to get additional details about an error. The SQL Server folks added their own custom field called SQL_DIAG_SS_PROCNAME which can be used to get the object that actually triggered the error.

Is there an equivalent for SQL Anywhere?

asked 17 Jul '12, 21:36

Bwery's gravatar image

accept rate: 0%

Try calling TRACEBACK(*).

You should carefully test this to make sure the results are still available by the time your application discovers there's a problem.

Another approach is to add EXCEPTION handlers to BEGIN blocks (mostly stored procedures in my case, triggers in your case) to log exceptions to a diagnostic table... that may be too much work, but (a) it's just additional code that doesn't disrupt any existing code in the triggers, (b) it means the client-side error handling can kept very simple, and (c) it is a blessing in the long run if you're doing a lot of development, especially massive enhancements.

permanent link

answered 18 Jul '12, 04:21

Breck%20Carter's gravatar image

Breck Carter
accept rate: 20%

edited 18 Jul '12, 04:22

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 17 Jul '12, 21:36

question was seen: 2,511 times

last updated: 18 Jul '12, 04:22