从php表单中获取OrderID值后,我试图将今天+1的当前日期和最大令牌值插入表中。
问题是我在存储过程中得到了空值。
我尝试过:
1)在INTO/AS
和QUEUEDATE
之前添加TOKENNUMBER
,但这没有用。
2)SET QUEUEDATE := (SELECT CURDATE());
,与TOKENNUMBER
相同。
3)声明并输入。
4)将select语句放在INSERT语句中。
CREATE PROCEDURE INSERTQUEUE (IN PATIENT_ORDERS_ORDERID INT(11),
OUT TOKENNUMBER INT(11), OUT QUEUEDATE DATE)
BEGIN
SELECT CURDATE() QUEUEDATE;
SELECT IF (((SELECT `TOKENNUMBER`FROM `patient_queuelogs`
WHERE `QUEUEDATE` = CURDATE()) IS NULL), 1 ,((SELECT MAX(`TOKENNUMBER`)
FROM `patient_queuelogs` WHERE `QUEUEDATE`=CURDATE())+1)) TOKENNUMBER;
INSERT INTO `patient_queuelogs`(`PATIENT_ORDERS_ORDERID`, `TOKENNUMBER`, `QUEUEDATE`) VALUES
(PATIENT_ORDERS_ORDERID,TOKENNUMBER,QUEUEDATE);
END;
---------------------------------------------------------------
CREATE PROCEDURE INSERTQUEUE (IN PATIENT_ORDERS_ORDERID INT(11),
OUT TOKENNUMBER INT(11), OUT QUEUEDATE DATE)
BEGIN
DECLARE QUEUEDATE DATE;
DECLARE TOKENNUMBER INT;
SELECT CURDATE() INTO QUEUEDATE;
SELECT IF (((SELECT `TOKENNUMBER`FROM `patient_queuelogs` WHERE `QUEUEDATE` = CURDATE()) IS NULL), 1 ,((SELECT MAX(`TOKENNUMBER`) FROM `patient_queuelogs` WHERE `QUEUEDATE` = CURDATE())+1)) INTO TOKENNUMBER;
INSERT INTO `patient_queuelogs`(`PATIENT_ORDERS_ORDERID`, `TOKENNUMBER`, `QUEUEDATE`) VALUES (PATIENT_ORDERS_ORDERID,TOKENNUMBER,QUEUEDATE);
END;