Ahh ok I see. So the problem is getting an error message from you trigger to your client application.
Technically, that isn't possible. As you say, MySQL 5.x doesn't support any sort of RaisError functionality like many of the other SQL servers do.
But to get around that, you could always do something you know will cause an error, and make that error include your message.
For example, if I did this:
-
CREATE TRIGGER myTable_BeforeInsert
-
BEFORE INSERT ON myTable
-
FOR EACH ROW
-
BEGIN
-
IF NEW.value <= 0 THEN
-
CALL `error`.`Value can not be zero or less.error`();
-
END IF;
-
END;
-
It would produce this error:
- ERROR 1305 (42000): PROCEDURE error.Value can not be zero or less.error does not exist
This includes my message between the "error." and ".error" strings, which can easily be extracted and used.
It's not pretty, but it gets the job done :)