MySQL Forums
Forum List  »  InnoDB

Cursor Not Looping . . .
Posted by: Liz Jamieson
Date: August 28, 2008 09:59AM

I am trying to write a stored procedure to print out the column names and count of columns in a database. But it stops after the first one. Any idea why?

Here is the code : ----------------------

BEGIN

DECLARE myCol VARCHAR(50) ;
DECLARE done INT DEFAULT 0 ;
DECLARE counter INT DEFAULT 0;

DECLARE cur1 CURSOR FOR SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS c, INFORMATION_SCHEMA.TABLES t
WHERE c.TABLE_NAME= t.TABLE_NAME AND
c.table_schema = 'fredDB' AND
c.CHARACTER_MAXIMUM_LENGTH > 1;

DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

OPEN cur1;

REPEAT

FETCH cur1 INTO myCol;
SET counter = counter + 1;
SELECT counter, myCol;

UNTIL done END REPEAT;

CLOSE cur1;

END

Options: ReplyQuote


Subject
Views
Written By
Posted
Cursor Not Looping . . .
4361
August 28, 2008 09:59AM
2635
January 22, 2009 03:59AM
2469
January 22, 2009 08:29AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.