MySQL Forums
Forum List  »  Stored Procedures

Re: Condition was unable to be followed by MySQL.
Posted by: Peter Brawley
Date: June 03, 2016 06:08PM

> How do I add stubs that monitor the variables?

Add select statements for them at points where their values would be diagnostic, eg after computing@total, add the stmt

select @total;

> And how do I compute the parameter value?

set @total = (select count(*) from ... );
if @total=0 then
  set @lev=1
elseif @total < 3 then
  set @lv=1
...
end if;

insert into gph_acquiredpeople 
set member_id p_memberid,encoded_mem_id=p_encodeid,date_encoded=now(),level_id=@lev;

update gph_memberstatus set available =0, taken=1 where id_number = p_encodeid;

As it turns out, the logic you show doesn't require PREPARE; just compute @lev and use it in the Insert statement.

BTW, column names should document themselves. If a column is a timestamp or datetime, naming it `date_encoded` misleads whoever is managing the database; timestamp_encoded ot ts_encoded would be better. If it's just a date, set it to curdate(), not to now().

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Condition was unable to be followed by MySQL.
445
June 03, 2016 06:08PM


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.