create procedure PGetMaxWaterNO()begin
   if not exists (select * from MSTB_BATCH_WATER where date(WATER_DATE)=curdate())
   begin
      insert into MSTB_BATCH_WATER (WATER_DATE,WATER_NO) values(NOW(),1);
   end;
   else
   begin
     update MSTB_BATCH_WATER set WATER_NO = WATER_NO+1
                             where date(WATER_DATE)=curdate();
     
   end;end;

解决方案 »

  1.   

    [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'begin
          insert into MSTB_BATCH_WATER (WATER_DATE,WATER_NO) values(NOW(),1);' at line 5
      

  2.   

    create procedure PGetMaxWaterNO()
    begin
       if not exists (select * from MSTB_BATCH_WATER where date(WATER_DATE)=curdate()) then
       begin
          insert into MSTB_BATCH_WATER (WATER_DATE,WATER_NO) values(NOW(),1);
       end;
       else
       begin
         update MSTB_BATCH_WATER set WATER_NO = WATER_NO+1
                                 where date(WATER_DATE)=curdate();
         
       end;
    end if;
    end;