Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE `string_procedure`()
- BEGIN
- DECLARE name_val VARCHAR(255);
- DECLARE status_update_val VARCHAR(255);
- -- Declare variables used just for cursor and loop control
- DECLARE no_more_rows BOOLEAN;
- DECLARE loop_cntr INT DEFAULT 0;
- DECLARE num_rows INT DEFAULT 0;
- DECLARE friends_cur cursor for SELECT CAST(friend_id AS CHAR(10000) CHARACTER SET utf8) as name_val FROM `friend` WHERE `friend_id` = '2';
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_more_rows = TRUE;
- OPEN friends_cur;
- the_loop: LOOP
- FETCH friends_cur INTO name_val;
- IF no_more_rows THEN
- CLOSE friends_cur;
- LEAVE the_loop;
- END IF;
- select name_val;
- END LOOP the_loop;
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement