传入参数 IN `base_date` int,IN `day_count` int,IN `table_name` varchar(128)需要声明一个游标
declare cur1 cursor for select code from day where date<=base_date order by code,date desc limit day_coun+1;
报错,day_count+1不行,要怎么写?

解决方案 »

  1.   

    这样mysql存储过程不支持的.楼主可以的话直接写死啊;
      

  2.   

    加begin end可以了
    有更好的办法请告知
      

  3.   

    DELIMITER $$DROP PROCEDURE IF EXISTS `testxx`.`DatabaseInit1`$$CREATE  PROCEDURE `DatabaseInit1`(in cou int)
    BEGIN
    DECLARE done INT DEFAULT 0;
    declare i_table varchar(100);
    declare i_tablecursor cursor for select item from asd limit cou ;
    declare continue handler for not found set done=1; 
    open i_tablecursor;
    repeat
    fetch i_tablecursor INTO i_table;
    if done =0 then
    set @sql= concat('delete from  asd where item',' = ','\'',i_table,'\'');
    prepare stmt from @sql;
    execute stmt;
    deallocate prepare stmt;
    end if;
    until done = 1 end repeat;
    END$$
    楼主帮我看看,begin end 怎么加?