MySQL Workbench 带分隔符的存储过程 END 不起作用
MySQL Workbench stored procedure END with delimiter not working
我正在使用 MariaDB 使用以下代码创建存储过程:
DROP PROCEDURE IF EXISTS P1;
DELIMITER // /* Set delimiter */
CREATE PROCEDURE P1(IN `date` DATE, IN `customer` INT, IN `bookingLocation` INT)
BEGIN /* Begin procedure */
/* Declare variables */
DECLARE currDate DATE;
DECLARE customerPlan INT;
DECLARE locCapacity INT;
DECLARE existingBookings INT;
SET currDate=CURRENT_DATE();
IF `date` < currDate THEN /* If date is in past */
SELECT "DATE CANNOT BE IN PAST" AS error;
ELSE
SELECT plan INTO customerPlan FROM `customers` WHERE customer_ID = `customer`; /* Get the customer's plan */
SELECT capacity INTO locCapacity FROM `locations`;
SELECT COUNT(*) FROM `desk_bookings` WHERE location=bookingLocation;
END IF;
END// /* End procedure */
DELIMITER ;
代码 运行 使用命令行正确,但是当我 运行 MySQL Workbench 中的代码时,我收到错误消息:
"/" is not valid at this position, expecting EOF, '/'
我通过删除 DELIMITER // /* Set delimiter */
行的评论解决了这个问题。
我正在使用 MariaDB 使用以下代码创建存储过程:
DROP PROCEDURE IF EXISTS P1;
DELIMITER // /* Set delimiter */
CREATE PROCEDURE P1(IN `date` DATE, IN `customer` INT, IN `bookingLocation` INT)
BEGIN /* Begin procedure */
/* Declare variables */
DECLARE currDate DATE;
DECLARE customerPlan INT;
DECLARE locCapacity INT;
DECLARE existingBookings INT;
SET currDate=CURRENT_DATE();
IF `date` < currDate THEN /* If date is in past */
SELECT "DATE CANNOT BE IN PAST" AS error;
ELSE
SELECT plan INTO customerPlan FROM `customers` WHERE customer_ID = `customer`; /* Get the customer's plan */
SELECT capacity INTO locCapacity FROM `locations`;
SELECT COUNT(*) FROM `desk_bookings` WHERE location=bookingLocation;
END IF;
END// /* End procedure */
DELIMITER ;
代码 运行 使用命令行正确,但是当我 运行 MySQL Workbench 中的代码时,我收到错误消息:
"/" is not valid at this position, expecting EOF, '/'
我通过删除 DELIMITER // /* Set delimiter */
行的评论解决了这个问题。