我正在使用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, '/'
1条答案
按热度按时间hgb9j2n61#
我能够通过删除
DELIMITER // /* Set delimiter */
行上的注解来解决此问题。