Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. CREATE PROCEDURE `string_procedure`()
  2. BEGIN
  3. DECLARE name_val VARCHAR(255);
  4. DECLARE status_update_val VARCHAR(255);
  5.  
  6. -- Declare variables used just for cursor and loop control
  7. DECLARE no_more_rows BOOLEAN;
  8. DECLARE loop_cntr INT DEFAULT 0;
  9. DECLARE num_rows INT DEFAULT 0;
  10. DECLARE friends_cur cursor for SELECT CAST(friend_id AS CHAR(10000) CHARACTER SET utf8) as name_val FROM `friend` WHERE `friend_id` = '2';
  11.  
  12.  
  13. DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_more_rows = TRUE;
  14. OPEN friends_cur;
  15. the_loop: LOOP
  16.  
  17. FETCH friends_cur INTO name_val;
  18.  
  19. IF no_more_rows THEN
  20. CLOSE friends_cur;
  21. LEAVE the_loop;
  22. END IF;
  23.  
  24. select name_val;
  25.  
  26.  
  27. END LOOP the_loop;
  28. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement