select
  a.scls1, a.scls2, a.scls3, a.nm, a.nm2
from afm90 a
where a.cls = :cls
  and (:scls1 is null or scls1 = :scls1)
  and (:scls2 is null or scls2 = :scls2)
  and ((:nm is null) or (upper(comnpack.MultiTOSingleBytesEx(a.nm||a.nm2))
                        like '%'||upper(comnpack.MultiTOSingleBytesEx(:nm))||'%'))
order by a.scls1, a.scls2, a.scls3