Re: Condition was unable to be followed by MySQL.
> 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().