create table t2 (
s1 int,
primary key (s1)
) engine=innodb;
create table t3 (
s1 int, key(s1),
foreign key (s1)
references t2 (s1)
) engine=innodb;
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails
create table error_log (error_message char(80))
CREATE PROCEDURE InsertWithLog (parameter1 INT)
BEGIN
DECLARE EXIT HANDLER for 1452
INSERT INTO error_log VALUES
( CONCAT ('Time: ', current_date,
'. Foreign key failure for Value = ', parameter1));
INSERT INTO t3 VALUES (parameter1);
END;