Can you please help me finding the error in the stored procedure? Thanks!!!
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;