for Select ENT_DET_ARTICULO, ENT_DET_CANTIDAD, ENT_DET_LARGO, ENT_DET_ANCHO from ENTALMACENDET
where ENT_DET_FOLIO = :FOLIO into roducto, :cantidad, ;Existencia, :Ancho :Largo do
begin
aux1 = '';
aux2 = '';
select MAT_ANCHO, MAT_LARGO from MATERIAL_DET where MAT_ID:=producto into :aux1, :aux2;
if (aux1 = '' and aux2 = '') then
insert into tabla (lo que sea)
else
update tabla (lo que sea)