我正在尝试创建一个存储过程来插入或更新基于输入变量的记录。但是,当我尝试编译 SP 时,只会告诉我以下信息:代码 1064,您的 SQL 语法有错误,请查看与您的 MySQL 服务器版本相对应的手册,以获取在第 80 行使用 near'' 的正确语法。我还没有找到解决方案。非常感谢你能给我的任何帮助。
我的SP代码如下:
DELIMITER $$
CREATE PROCEDURE `sp_sertup`(IN i_operation CHAR(1),
IN i_system VARCHAR(20),
IN i_subsystem VARCHAR(20),
IN i_ref VARCHAR(20),
IN i_significance VARCHAR(20),
IN i_rank VARCHAR(20),
IN i_implication VARCHAR(20),
IN i_loc1 VARCHAR(20),
IN i_loc2 VARCHAR(20),
IN i_task VARCHAR(20),
IN i_time VARCHAR(20),
IN i_cost1 VARCHAR(20),
IN i_cost2 VARCHAR(20),
IN i_note VARCHAR(20),
IN i_attach VARCHAR(20),
IN i_operation_text VARCHAR(20),
IN i_id_setup INT )
BEGIN
IF (i_operation = 'I') THEN
UPDATE setup_gs SET setup_status = 0 WHERE id_setup = id_setup;
INSERT INTO setup_gs(
SystemLabel,
SubsystemLabel,
RefLabel,
SignificanceLabel,
RankLabel,
ImplicationLabel,
Location1Label,
Location2Label,
TaskLabel,
TimeLabel,
Cost1Label,
Cost2Label,
NoteLabel,
attachmentText,
OperationsText,
setup_status
)
VALUES
(
i_system,
i_subsystem,
i_ref,
i_significance,
i_rank,
i_implication,
i_loc1,
i_loc2,
i_task,
i_time,
i_cost1,
i_cost2,
i_note,
i_attach,
i_operation_text,
1);
IF (i_operation = 'U') THEN
UPDATE
setup_gs
SET
SystemLabel = values(i_system),
SubsystemLabel = values(i_subsystem),
RefLabel = values(i_ref),
SignificanceLabel = values(i_significance),
RankLabel = values(i_rank),
ImplicationLabel = values(i_implication),
Location1Label = values(i_loc1),
Location2Label = values(i_loc2),
TaskLabel = values(i_task),
TimeLabel = values(i_time),
Cost1Label = values(i_cost1),
Cost2Label = values(i_cost2),
NoteLabel = values(i_note),
attachmentText = values(i_attach),
OperationsText = values(i_operation_text),
setup_status = 1
WHERE id_setup = i_id_setup;
END $$
DELIMITER ;