简体   繁体   English

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

[英]Mysql stored procedure giving error at runtime

I have created a stored procedure in Mysql, as : 我在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 ;

but when i call it using, 但是当我用

call test9('platinum');

it returns an error saying : 它返回一个错误说:

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

what i am doing wrong here? 我在这里做错了什么?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM