select
  a.cuedi, a.cucd, a.cunm, a.cuknm, a.cuzip, a.cuad1||a.cuad2 cuad,
  a.cutel, a.cufax,
  a.custp stp, decode(a.custp,null,'inputReadOnly','inputReadOnlyStp') readcolor
from afm03 a
where (:ccd is null or a.cucd like  :ccd||'%')
  and ((NVL(:stpflg, '0') <> '1' ) or (NVL(:stpflg, '0') = '1' and a.custp is null)) /*stpflg->0:廃止可,1:廃止不可(,2:マスタ無可)*/
order by a.cucd
