Mysql存储过程在运行时给出错误

时间:2010-06-29 05:25:18

标签: mysql stored-procedures mysql-error-1312

我在Mysql中创建了一个存储过程,如:

delimiter $$
drop procedure if exists test9$$
Create procedure test9(test_type varchar(20))
Reads sql data
begin

    Declare 1_id int;
    Declare 1_date varchar(20);
    Declare done int default 0;
    Declare cur1 cursor for 
        select id,name from buyers where ticket_type='test_type';
    Declare Continue handler for not found set done=1;

    Create temporary table if not exists ticketninja.history2(n_id int,n_date varchar(20));

    Open cur1;
        hist_loop:loop
            fetch cur1 into 1_id,1_date;

                if done=1 then
                    leave hist_loop;
                end if;

        insert into ticketninja.history2(n_id ,n_date) values(1_id,1_date);
        End loop hist_loop;
    close cur1;

    select * from history2;
    drop table history2;

End;

$$

delimiter ;

但是当我使用它时,

call test9('platinum');

它返回错误说:

#1312 - PROCEDURE ticketninja.test1 can't return 
a result set in the given context

我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

我认为您需要一个OUT变量(请参阅第一个代码示例here