日期:2014-05-16 浏览次数:21096 次
DROP PROCEDURE IF EXISTS Pro_test; CREATE PROCEDURE Pro_test() BEGIN DECLARE ret REAL; DECLARE no_more_departments INT; DECLARE cursor_name CURSOR FOR SELECT a FROM tbl_mytest; DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_more_departments=1; DROP TABLE IF EXISTS tbl_temp; CREATE TEMPORARY TABLE IF NOT EXISTS tbl_temp ( `tmp_ret` REAL , ) ; SET no_more_departments = 0; OPEN cursor_name; REPEAT FETCH cursor_name INTO ret; SET ret = ret*PI*100/180; INSERT INTO tbl_temp VALUES (ret); UNTIL no_more_departments END REPEAT; CLOSE cursor_name; SELECT tmp_ret FROM tbl_temp ORDER BY tmp_ret; END;