How can I call a script when table data changes in Sybase 12.5?

OS - UNIX. I want to call a shell script for external validation when the data in the table changes. Is it possible, and if so, how.

Many thanks.


Updated: Ideally I would like to call my external script once for any discrete operation: ie

  • update ...> call the script once
  • insert in ...> call the script once
  • bcp in> call script once
0


source to share


1 answer


I think you could call xp_cmdshell from a trigger.


Edit: As mentioned in the comments, the trigger fires only once for a data modification statement. (See books on the internet .) So if you have an update statement that affects 100 rows, the trigger will only fire once, not 100 times. This should take care of your first two points (update, insert).



Trigger does not light up on bcp. But bcp has to come from the command line, so not sure why you don't just add your shell script after each bcp command?

Here's some more info on calling xp_cmdshell from a trigger here .

Some additional comments: you did not describe your environment or what you are trying to accomplish. If you are in an OLTP environment, you need to make sure that your shell script will work fine if multiple updates happen to a table at once. If 3 users are doing updates at the same time, is your script still running if three of them are running at the same time? If you are doing this as part of some sort of OLAP or batch system, I'm not sure why you wouldn't add a shell script to the job flow.

+1


source







All Articles