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.

Based on code in a trigger I want to stop the insert or update that triggered it to fail. Since this is an atomic statement, can this be done at the database level?

asked 15 Jul '13, 12:17

judy's gravatar image

judy
46224
accept rate: 0%


Just call ROLLBACK TRIGGER within the trigger under the according condition.

To cite from the docs:

The ROLLBACK TRIGGER statement rolls back the work done in a trigger, including the data manipulation that caused the trigger to fire.

Optionally, a RAISERROR statement can executed. If a RAISERROR statement is executed, an error is returned to the application. If no RAISERROR statement is executed, no error is returned.

If a ROLLBACK TRIGGER statement is used within a nested trigger and without a RAISERROR statement, only the innermost trigger and the statement which caused it to fire are undone.

permanent link

answered 15 Jul '13, 12:26

Volker%20Barth's gravatar image

Volker Barth
40.2k362550822
accept rate: 34%

1
(15 Jul '13, 13:15) Breck Carter
Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×79
×12

question asked: 15 Jul '13, 12:17

question was seen: 2,471 times

last updated: 15 Jul '13, 13:15