2 replaced http://dba.stackexchange.com/ with https://dba.stackexchange.com/
source | link

I am not very proud of what I am about to show you but it must be done

Back on April 25, 2011 I wrote this post : http://dba.stackexchange.com/questions/2368/trigger-in-mysql/2371#2371Trigger in MySQL to prevent insertion

It explains how to interrupt a trigger midstream. You do so by deliberately launching an SQL statement that is syntactically correct but breaks on execution. This still was originally suggested on pages 254-256 of the book

enter image description here

because SIGNAL processing is not properly implemented (OK it wasn't implemented a lick)

With regard to your something like code, it should look something like this:

CREATE TRIGGER chk_dates
   BEFORE INSERT ON `job_history`
   FOR EACH ROW
    BEGIN
      DECLARE x INT;
      IF( NEW.end_date < OLD.start_date ) THEN
          SELECT dummy INTO x FROM mysql.user WHERE 1=1 LIMIT 1;
      ELSE .../// allow the data to be entered

Give it a Try !!!

I am not very proud of what I am about to show you but it must be done

Back on April 25, 2011 I wrote this post : http://dba.stackexchange.com/questions/2368/trigger-in-mysql/2371#2371

It explains how to interrupt a trigger midstream. You do so by deliberately launching an SQL statement that is syntactically correct but breaks on execution. This still was originally suggested on pages 254-256 of the book

enter image description here

because SIGNAL processing is not properly implemented (OK it wasn't implemented a lick)

With regard to your something like code, it should look something like this:

CREATE TRIGGER chk_dates
   BEFORE INSERT ON `job_history`
   FOR EACH ROW
    BEGIN
      DECLARE x INT;
      IF( NEW.end_date < OLD.start_date ) THEN
          SELECT dummy INTO x FROM mysql.user WHERE 1=1 LIMIT 1;
      ELSE .../// allow the data to be entered

Give it a Try !!!

I am not very proud of what I am about to show you but it must be done

Back on April 25, 2011 I wrote this post : Trigger in MySQL to prevent insertion

It explains how to interrupt a trigger midstream. You do so by deliberately launching an SQL statement that is syntactically correct but breaks on execution. This still was originally suggested on pages 254-256 of the book

enter image description here

because SIGNAL processing is not properly implemented (OK it wasn't implemented a lick)

With regard to your something like code, it should look something like this:

CREATE TRIGGER chk_dates
   BEFORE INSERT ON `job_history`
   FOR EACH ROW
    BEGIN
      DECLARE x INT;
      IF( NEW.end_date < OLD.start_date ) THEN
          SELECT dummy INTO x FROM mysql.user WHERE 1=1 LIMIT 1;
      ELSE .../// allow the data to be entered

Give it a Try !!!

1
source | link

I am not very proud of what I am about to show you but it must be done

Back on April 25, 2011 I wrote this post : http://dba.stackexchange.com/questions/2368/trigger-in-mysql/2371#2371

It explains how to interrupt a trigger midstream. You do so by deliberately launching an SQL statement that is syntactically correct but breaks on execution. This still was originally suggested on pages 254-256 of the book

enter image description here

because SIGNAL processing is not properly implemented (OK it wasn't implemented a lick)

With regard to your something like code, it should look something like this:

CREATE TRIGGER chk_dates
   BEFORE INSERT ON `job_history`
   FOR EACH ROW
    BEGIN
      DECLARE x INT;
      IF( NEW.end_date < OLD.start_date ) THEN
          SELECT dummy INTO x FROM mysql.user WHERE 1=1 LIMIT 1;
      ELSE .../// allow the data to be entered

Give it a Try !!!