I'm very new to triggers (and stored procedures), I've done a bit of searching and can't seem to find the right direction. Any help would be greatly appreciated.
Here is my situation: Thanks in advance!
I have 2 tables: Cat_Control (parent), Det_Control (child). They are related via an auto-incrementing ID (Cat_Control_ID)
When the user enters a new record into the Cat_Control table, I would like to automatically fill in several default records into the Det_Control table. These default records will be pre-defined based on the Cat_Control.Name field from the record that was just added to the Cat_Control table.
I'm sure this is way off base but I hope it will help to clarify what I'm looking to do:
1) For Each Cat_Control record added
2) insert record into Cat_Control table
3) set Cat_Control_ID = @@Identity (for record just added)
4) set Cat_Control_Name = Cat_Control.Name (for record just added)
5) Insert record into Det_Control table
5a)
Select Case Cat_Control_Name
case 'x'
insert record
case 'y'
insert record
case 'z'
insert record
6) loop back to step 5, to create 3 more "default records" into Det_Control table
7) loop back to Step 1 for next record
Thanks again guys (and gals) for your help.