MySQL Forums
Forum List  »  Triggers

Problem with Repeat?
Posted by: Chris Wasik
Date: March 09, 2006 08:58PM

Hello, I'm trying to build a stored procedure that will allow me to serialize some data and store it in a single column for efficiency reasons. I've started by writing a trigger for after inserts.

The problem is that when I add the "repeat... until done end repeat;" sections, the 'create trigger' no longer works!

This works:
delimiter //

create trigger my_test_trigger AFTER INSERT ON threadKeywords
FOR EACH ROW
BEGIN
DECLARE done tinyint DEFAULT 0;

DECLARE keywordStr text;
DECLARE thisKeyword tinytext;

DECLARE cur1 CURSOR FOR
SELECT keywords.name
from keywords, threads
where threadKeywords.keywordID=keywords.ID and threadKeywords.threadID=NEW.threadID;

DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
OPEN cur1;

//
delimiter ;


But this does not:

delimiter //

create trigger my_test_trigger AFTER INSERT ON threadKeywords
FOR EACH ROW
BEGIN
DECLARE done tinyint DEFAULT 0;

DECLARE keywordStr text;
DECLARE thisKeyword tinytext;

DECLARE cur1 CURSOR FOR
SELECT keywords.name
from keywords, threads
where threadKeywords.keywordID=keywords.ID and threadKeywords.threadID=NEW.threadID;

DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
OPEN cur1;

REPEAT
IF NOT done THEN

END IF;
UNTIL done END REPEAT;


//
delimiter ;

It tells me:

ERROR 1064 (42000): 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 'END IF;
UNTIL done END REPEAT' at line 12
mysql> delimiter ;

(If I remove the "if not done then end if;", it still doesn't work.)

I'm using the mysql command-line tool (I've also tried the Query Builder), and server version 5.0.18-Debian_8-log

Options: ReplyQuote


Subject
Views
Written By
Posted
Problem with Repeat?
5737
March 09, 2006 08:58PM
2020
March 10, 2006 01:56PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.