我正在编写一个简单的存储过程来获取数据并将其输入到表中
CREATE DEFINER = 'gunsdb-3939c99d-COPY-39393fb6'@'%'
PROCEDURE `gunsdb-3939c99d-COPY-39393fb6`.sp_entity_save(IN p_entity_id INT, IN p_entity_type_id INT, IN p_title_id INT, IN p_first_name VARCHAR(255), IN p_last_name VARCHAR(255), IN p_street_line_1 VARCHAR(255), IN p_street_line_2 VARCHAR(255), IN p_street_line_3 VARCHAR(255), IN p_town VARCHAR(255), IN p_county VARCHAR(255), IN p_postcode VARCHAR(255), IN p_email VARCHAR(255), IN p_telephone INT, IN p_company_name VARCHAR(500), IN p_company_desc VARCHAR(500), IN p_website VARCHAR(500), IN p_rfd_number INT, IN p_issuing_force VARCHAR(255), IN p_concent VARCHAR(255))
BEGIN
INSERT INTO tbl_entity (
entity_id,
entity_type_id,
title_id,
first_name,
last_name,
street_line_1,
street_line_2,
street_line_3,
town,county,
postcode,
email,
telephone,
company_name,
company_desc,
website,
rfd_number,
issuing_force,
concent
)
VALUES
(
p_entity_id,
p_entity_type_id,
p_title_id,
p_first_name,
p_last_name,
p_street_line_1 ,
p_street_line_2,
p_street_line_3 ,
p_town, @county ,
p_postcode,
p_email ,
p_telephone,
p_company_name ,
p_company_desc,
p_website,
p_rfd_number ,
p_issuing_force ,
p_concent
)
ON DUPLICATE KEY UPDATE
entity_type_id = p_entity_type_id,
title_id = p_title_id,
first_name = p_first_name,
last_name = p_last_name,
street_line_1 = p_street_line_1,
street_line_2 = p_street_line_2,
street_line_2 = p_street_line_2,
town = p_town,
county= p_county,
postcode = p_postcode,
email = p_email,
telephone = p_telephone,
company_name = p_company_name,
company_desc = p_company_desc,
website = p_website,
rfd_number = p_rfd_number,
issuing_force = p_issuing_force,
concent = p_concent
END
上面抛出了一个错误,但只要删除 BEGIN 和 END 它就可以正常工作,我不明白为什么。
我尝试添加 DELIMITER 但似乎遇到了同样的问题:
您的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,以了解在第 77 行 SQL1.sql 77 3 的“END”附近使用的正确语法
我正在使用 dbforge,但我也尝试过在 Navicat 中遇到同样的问题。