I have an insert trigger that is joining with a Estimate_Material_Table by an ID field. For all of the matching records in the Estimate_Material_Table, I need to see if any of the Cost Codes fields equal a certain value. If they do, then I need the Insert Block to proceed and create a new record.
This is working with my current setup, however it is inserting the new record for each Estimate Material Table record that matches the condition.
I'm trying to get it to only add once.
In Example, if the matching records from the Estimate Material Table had 3 records with Cost Code of 500, it should still only insert the new record once. Currently, it would insert 3 new records, which is not what I'm looking for.
It is almost like I need to group these matching Estimate records, see if any of the condition values exist, and then do the insert block instead of looping through each matching record. I just couldn't figure out how to do this.
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.
Question
kpcollier
I have an insert trigger that is joining with a Estimate_Material_Table by an ID field. For all of the matching records in the Estimate_Material_Table, I need to see if any of the Cost Codes fields equal a certain value. If they do, then I need the Insert Block to proceed and create a new record.
This is working with my current setup, however it is inserting the new record for each Estimate Material Table record that matches the condition.
I'm trying to get it to only add once.
In Example, if the matching records from the Estimate Material Table had 3 records with Cost Code of 500, it should still only insert the new record once. Currently, it would insert 3 new records, which is not what I'm looking for.
It is almost like I need to group these matching Estimate records, see if any of the condition values exist, and then do the insert block instead of looping through each matching record. I just couldn't figure out how to do this.
Any help is appreciated.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
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.