Jump to content

[SOLVED] help with printing out a message in a while loop in a stored procedure


fotobleu

Recommended Posts

DELIMITER $$

USE ad_behavior;

DROP PROCEDURE IF EXISTS maint_pauseAllCreativesNotActiveInAnyAdgroups $$

CREATE PROCEDURE maint_pauseAllCreativesNotActiveInAnyAdgroups()

BEGIN

DECLARE c_id INT(11) unsigned;

DECLARE f_s varchar(255);

DECLARE no_more_creatives INT;

 

-- gets creative_ids of all creatives that are not active in any adgroup;

DECLARE crs CURSOR FOR select creative_id, group_concat(status SEPARATOR " ") as full_status

                        from adgroup_creatives group by creative_id having full_status NOT LIKE '%active%';

DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_more_creatives=1;

 

-- loops trough the creative_ids that came back from the cursor above and

-- updates the creatives status to paused

 

SET no_more_creatives = 0;

OPEN crs;

    creatives_loop:WHILE(no_more_creatives = 0) DO

                    FETCH crs INTO c_id, f_s;

                    IF no_more_creatives = 1 THEN

                      LEAVE creatives_loop;

                    END IF;

                      UPDATE creatives SET STATUS = 'paused' WHERE id = c_id;

      SELECT concat('Creative : ',c_id,' was paused.') as message;

                    END WHILE creatives_loop;

CLOSE crs;

SET no_more_creatives = 0;

 

END $$

DELIMITER ;

 

it craps out on the SELECT concat line, saying its not the right syntax :

 

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 '('Creative : ',c_id,' was paused.') as message;

                    END WHILE cr' at line 23

 

anyone have any ideas, thanks

 

 

 

nevermind there were tabs before the select concat statement, stupid me

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.