I have this stored procedure

CREATE PROCEDURE `spCar`()
begin
declare exit1 int default 0;
declare rec1 char(50);
declare rec2 char(50);
declare vgas int;
declare cur1 cursor for select distinct car,driver from dates;
declare exit handler for not found set exit1=1;
open cur1;
repeat
fetch cur1 into rec2,rec1;

-- select gas into vgas from someTable where car=rec2 and driver=rec1;
select rec2,rec1,c_rest;

until exit1=1 end repeat;
close cur1;
end


if I uncommnet the line above ... the sp will not show anything if at some point the vgas variable is null

if I leave it commented will display the right number of records but I need my sp with vgas variable ... and this variable might be null at some point