你能帮我找一下存储过程中的错误吗?感谢!!!
CREATE PROCEDURE realiza_tracking_primer_lectura ( in v_campaign_id int(11), in v_ares_emails_id int(11), in v_userid int(11), in v_country varchar(2), in v_ip varchar(15), in v_useragent varchar(255), in v_time int(11)) BEGIN DECLARE ReadBefore int DEFAULT null; if v_campaign_id is Null then SELECT userid FROM tracking_lecturas WHERE ares_emails_id = v_ares_emails_id and userid = v_userid into ReadBefore; Else SELECT userid FROM tracking_lecturas WHERE campaign_id = v_campaign_id and userid = v_userid into ReadBefore; end if; if ReadBefore is Null then insert into tracking_lecturas (campaign_id, ares_emails_id, userid, ip, useragent, timestamp) values (v_campaign_id, v_ares_emails_id, v_userid, v_ip, v_useragent, v_time); end if; END DELIMITER;
答案 0 :(得分:0)
试试这个:
-- Dumping structure for procedure test.realiza_tracking_primer_lectura
DROP PROCEDURE IF EXISTS `realiza_tracking_primer_lectura`;
DELIMITER //
CREATE PROCEDURE `realiza_tracking_primer_lectura`(IN `v_campaign_id` int(11),IN `v_ares_emails_id` int(11),IN `v_userid` int(11),IN `v_country` varchar(2),IN `v_ip` varchar(15),IN `v_useragent` varchar(255),IN `v_time` int(11))
BEGIN
#Routine body goes here...
DECLARE ReadBefore int DEFAULT null;
if v_campaign_id is Null then
SELECT userid FROM tracking_lecturas WHERE ares_emails_id = v_ares_emails_id and userid = v_userid into ReadBefore;
Else
SELECT userid FROM tracking_lecturas WHERE campaign_id = v_campaign_id and userid = v_userid into ReadBefore;
end if;
if ReadBefore is Null then
insert into tracking_lecturas (campaign_id, ares_emails_id, userid, ip, useragent, timestamp) values (v_campaign_id, v_ares_emails_id, v_userid, v_ip, v_useragent, v_time);
end if;
END//
DELIMITER ;