Decs substitute

In one application, we are using DECS to monitor Open, Create, Update and DElete events on some forms. Our management decided not to use the DECS. Re-rewrite the Sql queries for all these events, as DECS is giving lot of troubles for us.For create and update events, I wrote the code in Query Save event. But it is not executing when it is composed or updated programatically.

(i.e. at manay other places, it is getting saved using Doc.save and composed using Compose statement.)

Where can I put this sql statements, so that it get fired everytime, one document get modified or created.

Thanks in Advance.