Jump to content
  • 0

nested triggers


sfa71

Question

Table 1 has a price that is used to compute a total stored in table 3 by multiplying by a number of units in table 2

There is a trigger on table 1 update  that revised a field on table 2 specifically to instigate an update in table 2  (so if the price changes it will recompute the total)

There is a trigger on table 2 update that revises the total on table 3

Formula-   Price(table 1) X units (table 2) = total (table 3)

When a change to the units in table 2 happens, the total in table 3 is recomputed via the trigger on update in table 2.

I want a change in table 1 to also execute the table 3  total - it is a very complicated trigger and I don't want to duplicate it on table 1 since there is no copy function for trigger specifics so i added an update flag on the table 2 that the trigger on table 1 sets true and that triggers the total update trigger on table 2.   All works and records updated properly

but......  

Problem is that the table 2 trigger doing the computation does not see the changed data in table 1.

Like the change to table 1 has not committed to the DB yet when the table 2 trigger is executed.

Is there a way to force the table 1 commit to the DB before trigger in table 2 executes? 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Caspio chat responded with:

Unfortunately, it's not possible to force the table 1 commit before the table 2 execution. What I suggest is using application tasks instead to run the process, however, it's only for a scheduled basis. Refer here:
https://howto.caspio.com/tasks/

Any other ideas? my options seem to be to replicate the trigger in table one and use #inserted records or just have the user remember to force an update via table 2.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...