mariadb 带分隔符的MySQL Workbench存储过程END不起作用

cgfeq70w  于 2022-11-08  发布在  Mysql
关注(0)|答案(1)|浏览(125)

我正在使用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, '/'
hgb9j2n6

hgb9j2n61#

我能够通过删除DELIMITER // /* Set delimiter */行上的注解来解决此问题。

相关问题