Please help me write a trigger that adds new rows to the table.
I have 3 tables in my database:
- Regions (id, name); id - primary
- Technique (id, name); id - primary
- Availability (id, region, technic, count); id - primary, region - foreign at Regions.id, Technik - foreign at technics.id.
I want to add a new line in “Accessibility” for each line of “Technique” when adding a line to “Regions”.
Sort of:
procedure void OnAddNewRegion(int region)
{
foreach (Row r in Technic)
{
Availability.Rows.Add(new Row(id, region, r.Id, 0));
}
}
But in a SQL trigger. I want to do the same when adding a new Technics line.
source
share