这是我在使用 MS SQL procs 的丰富经验之后的第一个 MySQL proc。在 MySQL Workbench 中,唯一的警报位于整个 proc 的 End 行,但它没有提供任何细节。
在完成了其他一些事情之后,我现在剩下的就是这个错误......
错误代码:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 '' 附近使用正确的语法
顺便说一句,我的所有变量都有@,但我确信这是一个问题。不确定它是否是/现在?
这是程序...
-- --------------------------------------------------------------------------------
-- Routine DDL
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE PROCEDURE `dbname`.`ImportAccountToGravityForm` ()
BEGIN
DECLARE intForm_id INTEGER;
DECLARE intLead_id_current INT;
DECLARE fltField_number_current FLOAT;
DECLARE vcrValue_current VARCHAR(200);
DECLARE intWeb_Site_Member_ID INT; -- id in import table
DECLARE vcrValue2 VARCHAR(200); -- SCHOOL
DECLARE vcrValue7 VARCHAR(200); -- ADDRESS LINE 1
DECLARE vcrValue8 VARCHAR(200); -- CITY
DECLARE vcrValue9 VARCHAR(200); -- STATE
DECLARE vcrValue10 VARCHAR(200); -- ZIP
DECLARE vcrValue11 VARCHAR(200); -- COUNTRY
DECLARE vcrValue12 VARCHAR(200); -- NON-STUDENT/STUDENT
DECLARE vcrValue13 VARCHAR(200); -- CLASS OF
DECLARE vcrValue14 VARCHAR(200); -- DESCRIPTION
DECLARE vcrValue16 VARCHAR(200); -- EMAIL
DECLARE vcrValue17 VARCHAR(200); -- AWARD
DECLARE vcrValue19 VARCHAR(200); -- SUBMITED BY - FULL NAME
DECLARE vcrValue20 VARCHAR(200); -- SUBMITTED BY - MAIL
DECLARE vcrValue23 VARCHAR(200); -- YEAR AWARDED
DECLARE vcrValue24_6 VARCHAR(200); -- FIRST NAME
DECLARE vcrValue24_3 VARCHAR(200); -- LAST NAME
DECLARE vcrValue25 VARCHAR(200); -- TITLE
SET intForm_id = 2;
SET intLead_id_current = -1;
SET vcrValue19 = 'Import from YM'; -- SUBMITED BY - FULL NAME
SET vcrValue20 = ''; -- SUBMITTED BY - MAIL
SET vcrValue12 = ''; -- STUDENT/ALUMNI
SET vcrValue14 = ''; -- DESCRIPTION
SELECT e.Web_Site_Member_ID, e.School, e.Home_Address_Line1, e.Home_City, e.Home_State_Abbrev, e.Home_Postal_Code,
e.Home_Country, e.Class_of, e.Email_Address, e.Membership, e.Year_award_or_scholarship_received,
e.First_Name, e.Last_Name, e.Title
INTO intWeb_Site_Member_ID,
vcrValue2, -- SCHOOL
vcrValue7, -- ADDRESS LINE 1
vcrValue8, -- CITY
vcrValue9, -- STATE
vcrValue10, -- ZIP
vcrValue11, -- COUNTRY
vcrValue13, -- CLASS OF
vcrValue16, -- EMAIL
vcrValue17, -- AWARD
vcrValue23, -- YEAR AWARDED
vcrValue24_6, -- FIRST NAME
vcrValue24_3, -- LAST NAME
vcrValue25 -- TITLE
FROM Export_fromYM_2012_06_25 e
WHERE e.Imported <> 'Y' AND e.Member_Type_Code = 'Student/Alumni'
ORDER BY e.Web_Site_Member_ID ASC;
INSERT INTO wp_hpvyvb_rg_lead
(form_id, date_created, ip, source_url, user_agent)
VALUES
(1, NOW(), '', 'import');
SET intLead_id_current = LAST_INSERT_ID();
IF intLead_id_current > 0 THEN
BEGIN
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 2, vcrValue2);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 7, vcrValue7);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 8, vcrValue8);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 9, vcrValue9);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 10, vcrValue10);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 11, vcrValue11);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 12, vcrValue12);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 13, vcrValue13);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 14, vcrValue14);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 16, vcrValue16);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 17, vcrValue17);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 19, vcrValue19);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 20, vcrValue20);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 23, vcrValue23);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 24.6, vcrValue24_6);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 24.3, vcrValue24_3);
INSERT INTO wp_hpvyvb_rg_lead_detail
(lead_id, form_id, field_number, value)
VALUES
(intLead_id_current, intForm_id, 25, vcrValue25);
UPDATE Export_fromYM_2012_06_25 SET Imported = 'Y', CustomFieldsMemberID = intLead_id_current WHERE @intWeb_Site_Member_ID = Web_Site_Member_ID;
END; -- IF
END;
$$
DELIMITER ;