这个问题现在已经花了我将近一个小时,我知道这是很简单的事情。
我收到以下错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IN VARCHAR(256), hl7PatientId IN VARCHAR(256))
BEGIN
DECLARE mainQueue INT' at line 1下面是我的查询,它看起来很正确:
DROP PROCEDURE IF EXISTS insert_data;
CREATE PROCEDURE `insert_data`(hl7PatientName IN VARCHAR(256), hl7PatientId IN VARCHAR(256))
BEGIN
DECLARE mainQueue INT DEFAULT 1;
SELECT `queueid` INTO mainQueue FROM `queues` WHERE `description` LIKE 'Main' AND `enabled` = 1 LIMIT 1;
INSERT INTO `queue_data`
(`queueid`, `patientname`, `patientid`, `location`, `creationtime`, `priority`)
VALUES
(mainQueue, hl7PatientName, hl7PatientId, 'QUEUE_NUMBER', TIMESTAMP(), '');
END;为此,我使用MySQL 5.0.77。
有人能看出这里面有什么不对劲吗?
发布于 2011-01-12 06:53:37
我整理了一下你的例子--注意分隔符和参数的用法!
drop procedure if exists insert_queue_data;
delimiter #
create procedure insert_queue_data
(
in p_patientname varchar(255), -- size ? i always prefix my params p_ and keep the same name as the db field
in p_patientid varchar(255) -- size ? are you sure this isnt an integer ?
)
begin
-- i always prefix my variables v_ and keep same name as the db field
declare v_queueid int unsigned default 1;
select queueid into v_queueid from queues where
description like 'Main' and enabled = 1 limit 1;
insert into queue_data(queueid, patientname, patientid, location, creationtime, priority) values
(v_queueid, p_patientname, p_patientid, 'QUEUE_NUMBER', now(), '');
end#
delimiter ;发布于 2011-01-12 06:49:03
颠倒IN和参数名称的顺序。
...(IN hl7PatientName VARCHAR(256), IN hl7PatientId VARCHAR(256))...https://stackoverflow.com/questions/4663533
复制相似问题