Created
May 9, 2012 10:24
-
-
Save ethanfu/2643593 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create procedure `testdb`() | |
begin | |
declare v_uid bigint(22); | |
declare v_code varchar(100); | |
declare v_value varchar(100); | |
declare _done TINYINT(1) default 0; | |
declare cur_user cursor for select id from `cdb_faqs`; | |
declare continue handler for not found set _done = 1; | |
open cur_user; | |
loop_xxx:loop | |
fetch cur_user into v_uid; | |
if _done=1 then | |
leave loop_xxx; | |
end if; | |
begin | |
declare _inner tinyint(1) default 0; | |
declare cur_param cursor for select title ,fpid | |
from `cdb_faqs` | |
where id=v_uid; | |
declare continue handler for not found set _inner = 1; | |
open cur_param; | |
loop_yyy:loop | |
fetch cur_param into v_code, v_value; | |
if _inner=1 then | |
leave loop_yyy; | |
end if; | |
insert into newtable values (v_uid, v_code, v_value); | |
end loop; | |
commit; | |
end; | |
end loop; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment