0

I have a trigger

 DELIMITER $$
  DROP TRIGGER IF EXISTS before_insert_on_emp $$
  CREATE TRIGGER before_insert_on_emp
  BEFORE insert ON empefforts
  FOR EACH ROW BEGIN
  DECLARE MSG VARCHAR(100);
  IF (NEW.TIMING) > 60
  THEN
    SET MSG='Error: TIMING must be <=60.';
  END IF;
 END$$
DELIMITER ;

I want to show the MSG VARIABLE value on console when the condition is true. How can I show this value. I am using mysql 5.0.18 version...

Mahesh Patidar
  • 184
  • 3
  • 15

1 Answers1

0

After doing some research i found that there is a way ... using SIGNAL like:

SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT = 'Error: TIMING must be <=60.';

UPDATE: example of procedure that prints a message:

DELIMITER //
CREATE PROCEDURE show_message()
BEGIN
    SELECT 'Error: TIMING must be <=60.'
END//
Stephan
  • 8,000
  • 3
  • 36
  • 42