0

I am new to triggers and select case. This is my first attempt. What I trying to do is, everytime a new row is entered in the rawdata table, the trigger should check for the name that was inserted in rawdata table. If that name doesn't appear in the stateDetails table, then insert another row in the stateDetails table with state = 'New ID' with that name. It gives me syntax errors.

Thanks

This is what I have tried

create trigger rawDataTrigger after insert on rawData
 for each row
BEGIN
 set @sID= (Select `Name` from rawdata where name not like '')
 set @checkID = (select `Name` from stateDetails where name = @sID)
 Select Case  
  when @checkID= null then
  (
    Insert into stateDetails (`sID`,`State`) VALUES (@sID,'new ID')
  )
  end
Ank
  • 6,040
  • 22
  • 67
  • 100

0 Answers0