我编写了以下存储过程来插入批量数据列表。存储过程成功编译但不插入任何条目。我对存储过程很新,不知道我错过了什么。任何人都可以评论:
这里我们尝试将URL列表和pe_tier添加到数据库中
CREATE DEFINER=`root`@`localhost` PROCEDURE `KKEventsInBulk`(
IN url varchar(4096),
IN emailArchivePath varchar (4096),
IN orgId int,
IN feedId int,
IN normalized_pattern_string varchar (4096),
IN uuid varchar(4096),
IN pe_tier int)
BEGIN
DECLARE p2 varchar(4000);
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
GET DIAGNOSTICS CONDITION 1
p2 = MESSAGE_TEXT;
SET p2=concat('Error ',p2);
SELECT p2;
END;
INSERT INTO kk_pattern (uuid, nomalized_pattern_string) values(uuid, normalized_pattern_string);
WHILE url != '' DO
IF EXISTS(SELECT 1 FROM url_event_detail ue where ue.url=url) THEN
INSERT INTO kk_event_detail(eventID,email_archive_path, patternID) values((select event_id from url_event_detail), email_archive_path,
(select id from pe_pattern p where p.normalized_pattern_string=normalized_pattern_string));
ELSE
BEGIN
INSERT INTO kk_waiting_on_ce(url, pe_tier, email_archive_path, pattern_id, org_id, feed_id)values
(url, pe_tier, email_archive_path,
(select id from pe_pattern p where p.normalized_pattern_string = normalized_pattern_string and p.uuid=uuid ),
org_id, feed_id);
END;
END IF;
END WHILE;
COMMIT;
END