创建一个检查日期的触发器[问题]

时间:2020-05-07 16:42:44

标签: mysql

我有一个问题..所需要的是创建一个触发器,以检查销毁日期(dateEmpr)是否小于退货日期(dateRetEff),将其增加至退货日期10天。返回

表结构

CREATE TABLE emprunter(
    numLivre VARCHAR(5),
    dateEmpr DATE,
    numInsc VARCHAR(5),
    dateRetEff DATE
);

这是我的代码..它告诉我这是错误的

CREATE TRIGGER verifier_date 
BEFORE INSERT ON emprunter
FOR EACH ROW 
BEGIN
    if((SELECT DATEDIFF(NEW.dateRetEff, NEW.dateEmpr) from emprunter ) <0) then
        dateEmpr =  DATE_ADD(OLD.dateEmpr, INTERVAL 10 DAY);
    end if;
END;

1064-您的SQL语法有错误;检查与您的MariaDB服务器版本相对应的手册,以在第6行的'= DATE_ADD(OLD.dateEmpr,INTERVAL 10 DAY)'附近使用正确的语法

1 个答案:

答案 0 :(得分:0)

function Parent(props){
  /*I wish to have a list of all the components of type <Child> 
  within props.children before making it to the return function.

  I would need to iterate over all props.children and their 
  children as well, and check if its a <Child> component. 
  I would weed out all other components/elements to only have a 
  list of all <Child> components
  */

  return(
    {props.children}
  )
}

function Child(props){
  return(
    {props.children}
  )
}

function App(){
  return(
    <Parent>

      <div>Just a div, would be weeded out</div>

      <Child>special component that Im looking for</Child>

      <div> //this div would be weeded out, 
        //but the <Child> component in it must be found!
        <Child>special component that Im looking for</Child>
      </div>

    </Parent>
  )
}

fiddle

相关问题