Insert and update one record in child table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 02:35 AM
Hello Everyone, I have a requirement, can someone please help me with this.
We need only one record to be inserted and same record is updated whenever the choice field 'covered' is updated.
There are 2 tables
Table 1 - core_company (Parent table) with a choice field 'covered' with choices 'yes' and 'no'.
Table 2 - vendor_suppliment (child table) with a date field 'not covered'.
- When the choice of covered is changed to 'yes' with scheduled job, then the 'not covered' field is updated to today's date and a record is inserted in table 2.
- When the choice of covered is changed to 'no' with scheduled job, then the 'not covered' field is cleared in table 2.
- Again when the choice of covered is changed to 'yes' with scheduled job, then the existing record which the date is cleared on change of choice to 'no', the date field is updated to today's date without inserting a new record in table 2.
- Again when the choice of covered is changed to 'no' with scheduled job, then the existing record which the date is updated to today's date on change of choice to 'yes', the date field is cleared in table 2.
This operation should be done on one record only, without inserting another record.
Thank you.