Jump to content
  • 1

triggered action on record insertion



Looking for a solution with a problem I am having with a triggered action.  Here is the scenario:

I have a table with a primary key(table 1).  This table has 3 child tables (table2, table3, and table4)  that link to the primary key on table1.  I have a triggered action, that when a record is inserted into table1, based on a field within that table, it should insert a record into one of the 3 child tables copying over the key.  I've tried a variety of different methods, to do this and it always seems to work with table2, but not tables3 and 4.  As far as troubleshooting, I created a back up of table3 and table4, and had the triggered action insert into them without any issues at all.  when it tries to do it in the table with the relationship (the copy does not have relationship established) it give me the error unable to insert due to data restrictions.  All 3 child tables have the exact same relationship (one to many), and I can not understand why it works on 1 table but not the other 2.  Any help is appreciated.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

@CoopperBackpack may have a point.

Referential integrity prevents records that to be inserted in table 2 if they dont have a parent on table 1. The reason why it causes an error is that during the trigger run, the #inserted is technically not a record inside the table yet, thus when you insert its value to table 2, the referential integrity prevents it to be inserted.


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.

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.

  • Create New...