0

I have created the following stored procedure for MySql schema on sqlfiddle

create procedure foobar(out msg int)
begin
set msg = 100;
end//

When i run the query to access the out parameter using

call foobar(@outval);
SELECT @outval;

I get the following error

ResultSet is from UPDATE. No Data.

I am not sure what am i doing wrong. Please suggest.

I am taking this as reference MySQL create stored procedure syntax with delimiter

Sql fiddle link: http://sqlfiddle.com/#!9/a2182/6

Community
  • 1
  • 1
Sumeet Kashyap
  • 143
  • 4
  • 15
  • In SQL Fiddle use the following trick in the stored procedure: `set msg = 100; select msg;` – wchiquito Mar 15 '15 at 08:32
  • @wchiquito Somehow the exact same code that was giving error earlier now works fine on sqlfiddle. Probably someone was working on the issue :) – Sumeet Kashyap Mar 16 '15 at 06:17

1 Answers1

3

You are missing the delimiter at the start, so it should be as

delimiter //
create procedure foobar(out msg int)
begin
 set msg = 100;
end;//

delimiter ;

Here is a test case in mysql cli

mysql> delimiter //
mysql> create procedure foobar(out msg int)
    -> begin
    ->  set msg = 100;
    -> end;//
Query OK, 0 rows affected (0.05 sec)
mysql> delimiter ;
mysql> call foobar(@outval);
Query OK, 0 rows affected (0.01 sec)

mysql> SELECT @outval;
+---------+
| @outval |
+---------+
|     100 |
+---------+
1 row in set (0.01 sec)
Abhik Chakraborty
  • 44,654
  • 6
  • 52
  • 63