select
  a.chgcd, a.chgnm, a.chgknm,
  a.chgstp, decode(a.chgstp,null,'inputReadOnly','inputReadOnlyStp') readcolor
from afm08 a
where (:chgcd is null or a.chgcd like :chgcd||'%')
  and (:chgnm is null or (upper(comnpack.MultiTOSingleBytesEx(a.chgnm||a.chgknm||a.chgnms))
                                like '%'||upper(comnpack.MultiTOSingleBytesEx(:chgnm))||'%')
      )
  and ((NVL(:stpflg, '0') = '1' ) or (NVL(:stpflg, '0') = '0' and a.chgstp is null))
order by a.chgcd
