Hi all,
My basic question is, is there a simple way of finding out if a select
statement executed within a stored proc returns something. I could go ahead,
do the fetch (the query is done with a cursor) and count how many records
were returned but looping over the result. In below proc the variable cnt
serves this purpose.
Is there an easier way to do this, like a cursor property or so?
Thanks
Olaf
DELIMITER //
DROP PROCEDURE IF EXISTS rfg2//
CREATE PROCEDURE rfg2()
READS SQL DATA
BEGIN
DECLARE idd INT;
DECLARE cnt INT;
DECLARE genos_done INT DEFAULT 0;
DECLARE genos CURSOR FOR select a1 from geno_cidr_raw where ident=28;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET genos_done=1;
SET cnt=0;
geno_block: BEGIN
OPEN genos;
REPEAT
FETCH genos INTO idd;
IF genos_done=0 THEN
SET cnt=cnt+1;
END IF;
UNTIL genos_done
END REPEAT;
CLOSE genos;
END geno_block;
SELECT cnt;
END//
DELIMITER ;
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]