Hi folks,
Today I ran into a similar situation on a Mysql 5.0.27 box
Here is how I made it work:
.................
DECLARE int_no_transfert INT UNSIGNED DEFAULT 0;
SET int_no_transfert = (SELECT TrFH_no_transfert FROM Transfert_fed_header WHERE (TrFH_no_encan = No_encan) AND (TrFH_start_date IS NULL) AND (TrFH_end_date IS NULL) LIMIT 1);
IF int_no_transfert !=0 THEN
-- it means select returned something and our local variable has changed
-- so here I treat the duplicate case....
ELSE
-- select returned no resultset... thus leaving untouched the local variable : int_no_transfert (0)
-- so, no duplicate.. proceed with insert.. or stuff

END