Hi.
In many previous ASE versions (up through 15.0), my standard practice when replacing a trigger in a live system was to simply use CREATE TRIGGER, without using DROP TRIGGER first. ASE allowed that, and I assume that it implicitly performed a DROP in an atomic operation with the CREATE.
The reason why the atomicity is important is because, without it, a user could perform a DML operation during the tiny window of time between the DROP and the CREATE, meaning some data could get into the database that was not subject to all the normal logic that the trigger would perform. I always have assumed (with no real proof) that my old way of doing it (i.e. CREATE with no DROP) prevented that possibility.
Now in ASE 16.0, my old method doesn't seem to work. ASE now disallows creating a trigger when a trigger with that name already exists. So I thought to use the CREATE OR REPLACE TRIGGER command. But that also didn't work for me, because ASE forbids it if I wasn't the user who created the trigger. Note that I am aliased to dbo in the database, and so is the user who created the trigger, but that apparently matters not to ASE.
Strangely, even though ASE16 forbids CREATE OR REPLACE TRIGGER, it still lets me DROP TRIGGER. So I am now explicitly dropping the trigger prior to creating it. That gets the job done, but now I assume it opens me up to the logic glitch I mentioned above, where a live user might insert a row during the window between my DROP and my CREATE.
Am I doing something wrong? Is there a permission setting that will allow CREATE OR REPLACE TRIGGER to work the way I want? Is there a way to force atomicity of the DROP and CREATE commands? Would the "ddl in tran" option be usable here? (I have no experience using that option). Must I limit all my trigger replacements to off-hours when no live users are in the system?
Thanks.
- John.