Mysql

使用 mySQL 創建觸發器。觸發器未編譯

  • January 7, 2018

它給了我一個錯誤標誌(引發應用程序錯誤)並且根本不會編譯。

CREATE DEFINER = CURRENT_USER TRIGGER 
`epharma`.`secure_emp` 
   BEFORE INSERT ON `employees` 
   FOR EACH ROW
       BEGIN 
           if (to char(sysdate,'hh24:mi') not between'08:00'and '18:00')) then 
               raise application error ('you may insert into employee table only during business hours');
           end if
   END;

儘管有神秘的氣氛,我想這就是你想要做的:

delimiter @
create or replace trigger irb_employees 
before insert on employees 
for each row 
   if (time(now()) not between time('08:00:00') 
                           and time('18:00:59')) 
   then 
       SIGNAL SQLSTATE '75000' 
           SET MESSAGE_TEXT = 'you may insert into employee table only during business hours';
   end if; @
delimiter ;

據我所知,您嘗試在產品中使用產品Oracle中的程式碼MySQL(或相反)。儘管 Oracle 公司擁有該產品MySQL,但產品使用不同的語法。確保您在屬於您正在使用的產品的文件中查找資訊。

引用自:https://dba.stackexchange.com/questions/194231