-1
DELIMITER $$
CREATE
PROCEDURE `cheque_alert`.`SavePoData`(IN poNo VARCHAR(25),IN releaseOrderDate DATE,IN expiryDate DATE,IN enteredDateTime DATETIME,IN enteredBy VARCHAR(8) ,
IN poItemCode VARCHAR(25),IN poItemsId CHAR(1),IN poItemDescription VARCHAR(75),IN quantity DOUBLE,IN amount DOUBLE
)
BEGIN
SELECT CASE WHEN ((SELECT 1 FROM `cheque_alert`.`po_main` WHERE po_no=poNo)>0)
THEN
INSERT INTO `cheque_alert`.`po_items_details`
(`pomainid_id`,
`po_item_code`,
`po_items_id`,
`po_item_description`,
`quantity`,
`amount`)
VALUES ((SELECT id FROM `cheque_alert`.`po_main` WHERE po_no =poNo),
poItemCode,poItemsId,poItemDescription,quantity,amount)
ELSE
INSERT INTO `cheque_alert`.`po_main`
(`po_no`,
`release_order_date`,
`expiry_date`,
`entered_date_time`,
`entered_by`)
VALUES (poNo,releaseOrderDate,expiryDate,enteredDateTime,(SELECT ID FROM cheque_alert.user_login WHERE USER_ID=enteredBy));
INSERT INTO `cheque_alert`.`po_items_details`
(`pomainid_id`,
`po_item_code`,
`po_items_id`,
`po_item_description`,
`quantity`,
`amount`)
VALUES ((SELECT LAST_INSERT_ID(),
poItemCode,
poItemsId,
poItemDescription,
quantity,
amount);
END;
END$$
DELIMITER ;
产生错误:如何使用选择案例在MySQL
Error Code : 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 'INTO
cheque_alert
.po_items_details
(pomainid_id
, `po_item_cod' at line 14
请让我知道这个错误我都做了些什么?
错误代码:1064 你有附近的一个错误 'ELSE \t \t BEGIN \t \t \t INSERT INTO'cheque_alert'.'po_main' \t \t \t(po_no,relea' 在列24 –