select
  a.ijan, a.jan, a.vjan, a.gdjnm||a.gdjstnd gdnmtxt,
  a.gdjnm, a.gdjstnd, gdnm, gdstnd,
  a.gdacst, a.gdsal, a.gdbcst, a.gdcst,
  a.gdcls9, m906.scls5 gdcls9nm,
  a.gdstp stp, decode(a.gdstp,null,'inputReadOnly','inputReadOnlyStp') readcolor
from  afm90 m906/*改廃区分*/,  afm02 a
where m906.cls(+)='6' and a.gdcls9=m906.scls1(+)
  and (:jan is null or a.jan like '%'||:jan)
  and ((NVL(:stpflg, '0') <> '1' ) or (NVL(:stpflg, '0') = '1' and a.gdstp is null))
order by a.jan