[selectRecords]
select 
	--H
	sh.den_no, han.han_name
	, sh.zeinuki_gaku
	, to_date(sh.syori_ymd, 'YYYYMMDD') as syori_ymd
	, to_date(sh.seikyu_ymd, 'YYYYMMDD') as seikyu_ymd
	, (case sh.nyuka_yotei_ymd when '' then null else to_date(sh.nyuka_yotei_ymd, 'YYYYMMDD') end) as nyuka_yotei_ymd
--	, sh.nonyu_no --,sh.nonyu_nm, 
--	, replace(replace(sh.nonyu_nm,chr(13)||chr(10),chr(10)),chr(10),chr(13)||chr(10)) as nonyu_nm
	, replace(replace(sh.biko1,chr(13)||chr(10),chr(10)),chr(10),chr(13)||chr(10)) as biko1
	, to_char(sh.upd_time,'yyyy/mm/dd') as upd_time
	--D
	, sm.row_no + 1 as row_no, sm.hin_cd,sm.hin_nm,sm.tani,sm.hacyu_su
--	, (sm.tanka * &19) as tanka
--	, (sm.kingaku * &19) as kingaku
	, (sm.tanka) as tanka
	, (sm.kingaku) as kingaku
	, sh.sir_cd,sh.sir_nm
	, sm.meisai_biko
	--mst
	, tan.tan_nm
	--uri
	, uri.tok_cd
	, uri.tok_nm
	, uri.nonyu_no
	, uri.nonyu_nm
from t_sir_m sm
inner join t_sir sh on (sm.den_no = sh.den_no)
left join t_uri uri on (uri.jucyu_flg = 1 and sm.jucyu_no = uri.den_no)
left join t_uri_m urim on (uri.den_no = urim.den_no and urim.row_no = 0 and sm.jucyu_no != 0)
left join m_sir msir on (msir.sir_cd = sh.sir_cd)
left join m_hanyo han on (sh.prc_sts = han.han_cd and mst_kbn = '01')
left join m_tanto tan on (tan.tan_cd = sh.tan_cd)
left join m_hin hin on (hin.hin_cd = sm.hin_cd)
where 1 = 1
and sh.del_flg = 0
and hacyu_flg = 1
and (sh.syori_ymd >= '&2' or '' = '&2') and (sh.syori_ymd <= '&3' or '' = '&3')
and (sh.sir_cd >= '&4' or '' = '&4') and (sh.sir_cd <= '&5' or '' = '&5')
and (sh.tan_cd >= '&6' or '' = '&6') and (sh.tan_cd <= '&7' or '' = '&7')
and (sm.hin_cd >= '&8' or '' = '&8') and (sm.hin_cd <= '&9' or '' = '&9')
and (hin.cat_cd >= '&10' or '' = '&10') and (hin.cat_cd <= '&11' or '' = '&11')
and (sh.den_no >= fnc_to_number('&12') or '' = '&12') and (sh.den_no <= fnc_to_number('&13') or '' = '&13')
--and (sm.hin_nm like '%&14%' or '' = '&14')
and ((fnc_translate_case(sm.hin_nm) LIKE '%'||fnc_translate_case('&14')||'%') or ('&14' = ''))


order by sh.syori_ymd,sh.den_no,sm.row_no
;