0
Answer

Trigger to update field based upon what's inserted

Don

Don

10y
710
1
Hi All,
 
Likely an easy question, but I can't find exactly what I need by searching. Running SQL2000. I have a VB program that looks at our ERP data every 30 minutes and sends out emails or updates data in order to address common things missed by our sales people, etc.
 
I now have a need to have one section of the program to be instantaneous so I want to make a trigger. Here's a section from the old program (it's fitlered to only those records that are missing the ProdFam field:
 
    Do While Not rsSales.EOF
        Select Case Left(rsSales.Fields("IMA_ItemID").Value, 5)
       
        'AMAT et al
        Case "1014-", "1014A", "1095-", "1995-", "2028B", "2028P", "2092-", "2096-", "3030-", "3095-", "3096-", "4028-"
            rsSales.Fields("IMA_ProdFam").Value = "AMAT"
        
        'Analog SCR
        Case "1027A", "1028A", "1029A", "1029B", "1029C", "1029D", "1037A", "1039-", "1039I", "3027-", "3037-", "3337-", "3629C", "3869"
            rsSales.Fields("IMA_ProdFam").Value = "Analog SCR"
        
 (many more cases here, removed for ease of reading)
        
        End Select
       
        rsSales.Update
        rsSales.MoveNext
    Loop

Basically, it just looks at the root of the ItemID and decides what product family the Item belongs in and then sets the ProdFam field.

I have no idea how to do this in a trigger. Can someone give me a start on this or is that asking too much?

I will appreciate any help you can give me,
Don