MySQL Forums
Forum List  »  MySQL Shell

Re: Error 1064
Posted by: Peter Brawley
Date: December 02, 2021 09:42AM

Usually best to test an algorithm before putting it in an sproc, eg ...

set @file_no = 2;
set @list_name = '0,2,1';
set @a = find_in_set(@file_no, @list_name);
select @,if(@a>0,1,2);
+----------+------------+------+--------------+
| @file_no | @list_name | @a   | if(@a>0,1,2) |
+----------+------------+------+--------------+
|        2 | 0,2,1      |    2 |            1 |
+----------+------------+------+--------------+

Then re the sproc, you forgot to declare it ...

drop procedure if exists test;
delimiter //
create procedure test()
begin
  set @file_no = 2;
  set @list_name = '0,2,1';
  set @a = find_in_set(@file_no, @list_name);
  -- select @a;
  if @a > 0 then select 1;
  else select 2;
  end if;
end //
delimiter ;
call test();
+---+
| 1 |
+---+
| 1 |
+---+

Options: ReplyQuote


Subject
Views
Written By
Posted
538
December 02, 2021 01:13AM
Re: Error 1064
423
December 02, 2021 09:42AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.