MySQL Forums
Forum List  »  Stored Procedures

Having trouble with Procedure
Posted by: John Kotuby
Date: October 10, 2017 02:31PM

Having trouble with this proc. I come from Microsoft SQL background. The code makes sense to me but I get Syntax errors. Any help appreciated. I am under a time constraint. Here is the code:

BEGIN

SET @source_id := 0;
SET @dest_id := 0;
select @source_id = list_id from mw_list l where list_id > @source_id LIMIT 1;

WHILE @source_id IS NOT NULL
select @dest_id = list_id from mw_list where list_id > @dest_id and list_id <> @source_id LIMIT 1;

WHILE @dest_id IS NOT NULL
IF NOT EXISTS (SELECT * from test_list_subscriber_action WHERE source_list_id = @source_id AND
target_list_id = @dest_id AND source_action = ‘unsubscribe’ AND target_action = ‘unsubscribe’)

THEN
INSERT test_list_subscriber_action @source_id, ‘unsubscribe’, @dest_id, ‘unsubscribe’;
END IF;

select @dest_id = list_id from mw_list where list_id > @dest_id and list_id <> @source_id LIMIT 1;

END WHILE;
select @source_id = list_id from mw_list l where list_id > @source_id LIMIT 1;
END WHILE;

END

Options: ReplyQuote


Subject
Views
Written By
Posted
Having trouble with Procedure
3269
October 10, 2017 02:31PM
526
October 10, 2017 03:41PM
533
October 10, 2017 04:18PM


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.