call spQuery_Combo_UM('PAQ12');

DROP PROCEDURE IF EXISTS spQuery_Combo_UM;
CREATE PROCEDURE spQuery_Combo_UM(	
	varCodigo varchar(19)
)
BEGIN 
 if varCodigo <> '' and varCodigo is not null  then
   	select F.id_um_destino as id_um, U.nombre 
    from _sv_factor_conv F
    inner join _sv_unid_medida U ON F.id_um_destino = U.id_um
    where F._estado='A'
    and U._estado = 'A'
    and F.id_um_origen = varCodigo
    order by U.nombre;
 else
    select id_um, nombre
    from _sv_unid_medida  
    where _estado='A'
    order by nombre;
 end if;  
END;