MySQL Forums
Forum List  »  Stored Procedures

Re: Having trouble with Procedure
Posted by: John Kotuby
Date: October 10, 2017 03:41PM

OK here is an update. I had some luck getting syntax squared away. For one thing, the code had Microsoft Word "Smart Quotes" around some string values instead of real single-quotes. The I did not have a DO command after the while (it is not needed in MSSQL). Here is the latest Procedure that complied and saved. Thanx all.

====================================================
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 DO
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 DO
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 INTO test_list_subscriber_action (source_list_id, source_action, target_list_id, target_action)
VALUES (@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
=====================================

Now I must check the Logic with Testing...thanks

Options: ReplyQuote


Subject
Views
Written By
Posted
3269
October 10, 2017 02:31PM
Re: Having trouble with Procedure
525
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.