一.不带参数的游标for循环 首先编写存储过程的整体结构,如下: create or replace procedure test_proc is v_date date; --变量定义 begin select sysdate into v_date from dual; end test_proc; 定义游标: create or replace procedure test_proc is v_date date; --定义变量 cursor cur is select * from ld
CREATE PROCEDURE `test`.`new_procedure` () BEGIN DECLARE done INT DEFAULT FALSE; -- 需要定义接收游标数据的变量 ); -- 游标 DECLARE cur CURSOR FOR SELECT i FROM test.t; -- 遍历数据结束标志 DECLARE done INT DEFAULT FALSE; -- 将结束标志绑定到游标 DECLARE CONTINUE HANDLER FOR NOT FOUND S
delimiter // create procedure p2() begin declare row_id int DEFAULT 0; declare row_num int DEFAULT 0; declare done int default False; declare temp int DEFAULT 0; declare my_cursor cursor for select id, num from a; declare continue handler for not fou