select
  a.cucd, a.cunm,
  a.rmtype
from elm01 a
where (:ccd is null or a.cucd like '%'||:ccd||'%')
  and (:cnm is null
      or (upper(comnpack.MultiTOSingleBytesEx(a.cunm)) LIKE '%'||upper(comnpack.MultiTOSingleBytesEx(:cnm))||'%') )
  and (:rmtype = '9'
      or (:rmtype <> '9' and a.rmtype = :rmtype)
    )
order by a.cucd
