use st;
DELIMITER $$
CREATE PROCEDURE 2in1()
begin
declare bm char(8);
declare found boolean default true;
declare bm_ cursor for select table_name from information_schema.tables where table_schema='st' limit 1,15000;
declare continue handler for not found set found=false;
open bm_;while found do
fetch bm_ into bm;
if found=true then
begin
declare rq_ date;
declare found2 boolean default true;# declare rq_bcf cursor for select distinct(rq) from bm; SET @STMT=CONCAT('declare rq_bcf cursor for select distinct(rq) from ',bm,';');
PREPARE STMT FROM @STMT;
EXECUTE STMT;
declare continue handler for not found set found2=false;
open rq_bcf;
while found2 do
fetch rq_bcf into rq_;
end while;
close rq_bcf;
end;
end if;
end while;
close bm_;
end$$
delimiter ;
运行后提示: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 'decla
re continue handler for not found set found2=false;
open rq_bcf;
while foun' at line 23
参见 http://topic.csdn.net/u/20120609/00/0abebfa5-9a35-4375-82fc-6733f10369d1.html?09780595148663154
DELIMITER $$
CREATE PROCEDURE 2in1()
begin
declare bm char(8);
declare found boolean default true;
declare bm_ cursor for select table_name from information_schema.tables where table_schema='st' limit 1,15000;
declare continue handler for not found set found=false;
open bm_;while found do
fetch bm_ into bm;
if found=true then
begin
declare rq_ date;
declare found2 boolean default true;# declare rq_bcf cursor for select distinct(rq) from bm; SET @STMT=CONCAT('declare rq_bcf cursor for select distinct(rq) from ',bm,';');
PREPARE STMT FROM @STMT;
EXECUTE STMT;
declare continue handler for not found set found2=false;
open rq_bcf;
while found2 do
fetch rq_bcf into rq_;
end while;
close rq_bcf;
end;
end if;
end while;
close bm_;
end$$
delimiter ;
运行后提示: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 'decla
re continue handler for not found set found2=false;
open rq_bcf;
while foun' at line 23
参见 http://topic.csdn.net/u/20120609/00/0abebfa5-9a35-4375-82fc-6733f10369d1.html?09780595148663154
help me!!
help me!!!
DELIMITER $$
CREATE PROCEDURE 2in1()
begin
declare bm char(8);
declare found2 boolean default true;
declare bm_ cursor for select table_name from information_schema.tables where table_schema='st' limit 1,15000;
declare continue handler for not found set found2=false;
open bm_;while found2 do
fetch bm_ into bm;
if found=true then
begin
declare rq_ date;
declare found boolean default true;# declare rq_bcf cursor for select distinct(rq) from bm; SET @STMT=CONCAT('declare rq_bcf cursor for select distinct(rq) from ',bm,';');
PREPARE STMT FROM @STMT;
EXECUTE STMT;
# DEALLOCATE PREPARE stmt; open rq_bcf;
while found do
fetch rq_bcf into rq_;
end while;
close rq_bcf;
end;
end if;
end while;
close bm_;
end$$
delimiter ;
运行提示:
ERROR 1324 (42000): Undefined CURSOR: rq_bcf真是没有办法了,请教再请教。