In cleaning up this answer I learnt a bit about TRIGGER
s and stored procedures in MySQL, but was stunned that, while BEFORE INSERT
and BEFORE UPDATE
triggers could modify data, they seemingly couldn't cause the insert/update to fail (ie. validation). In this particular case I was able to get this to work by manipulating the data in such a way as to cause a primary key duplicate, which in this particular case made sense, but doesn't necessarily make sense in a general sense.
Is this sort of functionality possible in MySQL? In any other RDBMS (my experience is limited to MySQL sadly)? Perhaps a THROW EXCEPTION
style syntax?