分类:
2006-08-09 23:30:57
DECLARE cursor_name CURSOR FOR SELECT_statement; |
OPEN cursor_name; |
FETCH cursor_name INTO variable list; |
CLOSE cursor_name ; |
/*定义游标*/ DECLARE dept_csr CURSOR FOR SELECT department_id,department_name, location FROM departments; /*错误处理*/ DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_more_departments=1; SET no_more_departments=0; OPEN dept_csr;/*打开游标*/ REPEAT /*获得结果*/ FETCH dept_csr INTO l_department_id,l_department_name,l_location; UNTIL no_more_departments END REPEAT; CLOSE dept_csr; /*关闭游标*/ SET no_more_departments=0; |
PREPARE statement_name FROM sql_text /*定义*/ EXECUTE statement_name [USING variable [,variable...]] /*执行预处理语句*/ DEALLOCATE PREPARE statement_name /*删除定义*/ |