I've created the following stored procedure:
CREATE DEFINER=`root`@`localhost` PROCEDURE `ABON_PLATA`(DATE_BAL1 datetime)
BEGIN
DECLARE IMSI1 varchar(6);
DECLARE DATE1 datetime;
DECLARE ID_U1 integer;
DECLARE PAY1 double;
DECLARE PAYSUM double;
DECLARE OLD1 double;
DECLARE REASON1 varchar(16);
DECLARE FLAG integer DEFAULT 0;
DECLARE C1 CURSOR FOR SELECT ID_U FROM podkl_otkl_uslug WHERE IMSI1=IMSI;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET FLAG=1;
OPEN C1;
REPEAT
FETCH C1 INTO ID_U1;
IF FLAG=0 THEN
SELECT SUM(PAY) INTO PAY1 FROM uslugi WHERE ID_U1=ID_U AND DATE_PODKL<DATE_BAL1 AND DATE_OTKL IS NULL;
SET REASON1 = 'ABON PLATA';
SET DATE1 = DATE_BAL1;
SET PAYSUM = `NEW`-PAY1;
SET OLD1 = `NEW`;
END IF;
INSERT history (`DATE`, REASON, `NEW`, OLD, IMSI) VALUES (DATE1, REASON1, PAYSUM, OLD1, IMSI1);
UNTIL FLAG=1
END REPEAT;
CLOSE C1;
END
It is used to simulate subscribtion fee of mobile operator. As I am trying to call it, I get the notorious error:
CALL ABON_PLATA(2013-07-07 12:00:00);
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 '12:00:00)' at line 1
Considering it is an error at line 1, I get extremely confused. What super obvious am I missing?