select
  a.iseq as piseq,
  null as iseq30,
  a.spktcd,
  a.vseq as cvseq,
  a.cuiseq,
  :vseq as vseq,
  a.vlin,
  to_char(a.ydat, 'yyyy/mm/dd') as dat2,
  to_char(a.climit, 'yyyy/mm/dd') as adat,
  a.cuslip2 as cuslip,
  comnpack.ClipSltext(b.sltext,14) as bbno,
  comnpack.ClipSltext(b.sltext,2) as dcubcd,
  ltrim(Get_Sltext(b.sltext,'D2')) as dtxt1,
  ltrim(Get_Sltext(b.sltext,'D3')) as dtxt2,
  ltrim(Get_Sltext(b.sltext,'L3')) as ltxt1,
  ltrim(Get_Sltext(b.sltext,'L4')) as ltxt2,
  a.ijan,
  m02.jan,
  m02.gdjnm,
  m02.gdjstnd,
  m02.gdcls9,
  m90.scls5 gdcls9nm,
  a.ypno as jpno,
  a.ypno as tpno,
  a.cst as ncst,
  a.sal,
  a.fcst as gdcst,
  decode(a.jmcat,'1',null,'2','サンプル・交換品','3','添付品',null) jmcatnm,
  to_char(a.jdat, 'yyyy/mm/dd') as dat3,
  to_char(a.vdat, 'yyyy/mm/dd') as vdat,
  null as hvseq,
  null as chgcdnm,
  null as idat,
  null as upchgnm,
  null as udat,
  a.com as txt1,
  null as gdjnm2,
  null as gdjstnd2,
  null as vno,
  null as snum1,
  a.ntcst,
  case when :cutaxcls = '1' and :cutax = '1' then a.ntcst
  else a.cst end as dsp_ncst,
  a.hpno,
  m03.cunm,
  m032.spnm
from afm032 m032, afm03 m03,
  afm90 m90,afm02 m02,afr31txt b, afr3123 a
where a.cls='23' and a.cls1='0' and a.sts in ('0','1') and a.ceslip2='05'
  and a.ktktcd=:ktktcd
  and a.cucd=:cucd
  and a.cuscd=:cuscd
  and a.vseq=:cvseq
  and a.cuiseq=:cuiseq
  and a.iseq=b.iseq(+)
  and a.ijan=m02.ijan(+)
  and m90.cls(+)='6' and m02.gdcls9=m90.scls1(+)
  and a.cucd=m03.cucd(+)
  and a.cucd=m032.cucd(+) and a.cuscd=m032.cuscd(+)
