I have a Sybase SQL Anywhere 17 server running on Linux, and I was wondering if it is possible to create a database trigger to execute a local operating system system command when an UPDATE is down on a particular database record? Essentially, if a database table.field is updated to "complete", execute /usr/local/bin/notify

I have done this previously with other database systems, but looking over the SQLAW17 documentation, I can't find any references on how to do this (the trigger documentation seems to refer to stored procedures etc, not clear if I can or should do this as a stored procedure, etc).

Any advice would be appreciated!

1 Answer 1


Well, trigger is essentially a stored procedure. It just created with create trigger instead of create procedure.

Inside the trigger (as well as inside any procedure), you can execute external tool with xp_cmdshell.

So, assuming you have a table tbl with two fields name and status you can have something like:

create trigger on_complete after update on tbl 
   declare msg text;
   declare cmd text;

   if new.status = "completed" then
      set msg = "Completed " || new.name
      set cmd = '/usr/local/bin/notify "'||msg||'"';
      call xp_cmdshell(cmd, 'no_output' );
   end if

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.