dynamic cursors in mysql

dynamic cursors in mysql

am 30.03.2007 10:18:52 von dbkarthik

I have a problem in writing a dynamic cursor

CREATE PROCEDURE testassign(IN testdb varchar(50))
BEGIN
DECLARE a varchar(50);
DECLARE b varchar(50);
set @tab1 = "SELECT test1,test2 FROM testdb.testtable;";
DECLARE curtest CURSOR FOR @tab1
OPEN curtest;
FETCH curtest INTO a, b;
CLOSE curtest;
SELECT a ,b ;
END//

actually the purpose of me writing this dynamic cursor is i will get
the database name as a input parameter and my cursor should select the
data accordingly.

but im not able to do the same. can anyone help me out with different
solution.