DELIMITER //
CREATE PROCEDURE test()
BEGIN
DECLARE sql_error TINYINT DEFAULT FALSE;
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION
SET sql_error = TRUE;
INSERT INTO general_ledger_accounts VALUES (130, 'Cash');
SELECT '1 row was inserted.' AS message;
END;
IF sql_error = TRUE THEN
SELECT 'Row was not inserted – SQL exception encountered.'
AS message;
END IF;
END//
Error Translation: If MySQL sees something it does not like give up and go home, just tell the user something bad happened but make no effort to help identify the problem
This is the System Administrator when she sees this error, do you think she will want to buy any more of your code?