select a.sts,a.cuslip1,a.gdflg,
    to_char(a.jdat,'yyyy/mm/dd') jdat,to_char(a.climit,'yyyy/mm/dd') climit,
    a.spktcd spktcd1,h1.ktktnm spktnm1,
    cuscd spktcd2,h2.ktktnm spktnm2,
    a.cuslip2,a.iseq,a.vlin,a.jan,a.ijan,a.mvpno,a.cst,a.sal,a.com,a.jmcat,
    a.chgcd,a.upchg,a.pkbn1,a.pkbn2,
    c.gdjnm,c.gdcnum,c.gdbnum,c.gdstun,c.gdcls9,g.scls5 gdcls9nm,
    e.chgnm chgcdnm,to_char(a.idat,'yyyy/mm/dd hh24:mi') idat,f.chgnm upchgnm,
    case when a.udat=a.idat then null else to_char(a.udat,'yyyy/mm/dd hh24:mi') end udat 
from afm05 h2,afm05 h1,afm90 g,afm08 f,afm08 e,afm02 c,afr3123 a
where a.cls='23' and a.cls1='0' and a.sts='1' and a.ceslip2='12'
    and a.ktktcd=:ktktcd
    and a.cucd='0000'
    and a.vseq=:vseq and a.cuiseq=:cuiseq
    and a.ijan=c.ijan(+)
    and g.cls(+)='6' and c.gdcls9=g.scls1(+)
    and a.chgcd=e.chgcd(+)
    and a.upchg=f.chgcd(+)
    and a.spktcd=h1.ktktcd(+)
    and a.cuscd=h2.ktktcd(+)
order by a.vlin