Fixed errors in the sql script.

One of the trigger does not work and I am not sure why. It does not
return an error and does not return at all...