Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Change a Trigger??
Mon, Nov 1 2021 1:36 AMPermanent Link

Ian Branch

Avatar

Hi Team,
I have the following trigger in my Database..
{sql}
BEGIN
IF OLDROW.JobStatus <> NEWROW.JobStatus THEN SET NEWROW.DateStatusChanged = CURRENT_DATE;
END IF;
END
{sql}
This is a Before Update Trigger.

I need this now to perform the action on After Update Trigger.
Can I do this?
If so, how please?

Regards & TIA,
Ian
Mon, Nov 1 2021 3:57 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian


I'm sure someone much cleverer than me will have a way but I would advise against doing what you ask.

Firstly I'm not sure why you would want to do it and secondly, unless I'm wrong (very possible) you would be heading for a disaster:

1. someone updates the record and hist post
2. your after update trigger fires and alters the record
3. you now have an altered record so goto 2
4.woops never get here

Is something else changing JobStatus? If not the before update (read before post) is the right place for the trigger, if not you haven't given enough information to say where it should be


Roy Lambert
Mon, Nov 1 2021 5:45 AMPermanent Link

Ian Branch

Avatar

Hi Roy,
The Job Status is changed by any one of 3 or 4 different Apps.  Contention is extremely unlikely as the work is streamed, one action after another..
The Before Update Trigger is to save me having to duplicate code in all the Apps to achieve the same thing.
Unfortunately I think the Before Update trigger is triggering, pun intended, my Logging routine in the Apps. Frown
Anyway, I was just curious if it could be done.

Regards,
Ian
Mon, Nov 1 2021 8:25 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian

>The Job Status is changed by any one of 3 or 4 different Apps. Contention is extremely unlikely as the work is streamed, one action after another..
>The Before Update Trigger is to save me having to duplicate code in all the Apps to achieve the same thing.

Good thinking, and exactly what its for.

>Unfortunately I think the Before Update trigger is triggering, pun intended, my Logging routine in the Apps. Frown

If that's all the code is then I don't see how it can be triggering a different routine, unless that is triggered somewhere by a change in DateStatusChanged or JobStatus

>Anyway, I was just curious if it could be done.

and now you know <giggle>

Roy
Image