Please help me to write trigger that, adds new rows in table
I have 3 tables in my database.
- Regions (id, name); id - primary
- Technics (id, name); id - primary
- Availability (id, region, technic, count); id - primary, region - foreign on Regions.id, Technik - foreign on technics.id
I want to add new row in Availability for each Technics row on adding row in Regions.
Somethink like:
procedure void OnAddNewRegion(int region)
{
foreach (Row r in Technic)
{
Availability.Rows.Add(new Row(id, region, r.Id, 0));
}
}
But in SQL trigger. Same I want to do on the adding new Technics row