[getColList]
select hin_cd, to_char(size_h,'FM990.0') as col_view
from m_hin
where dhin_cd = ':hin_cd'
order by size_h

[load_grdList]
select
  h26.han_cd
, h26.han_name as hin_class
, h26.sort_key
, max(case when(mh.hin_cd = ':chk01')then(m.mng1_flg)else(0)end) as chk01
, max(case when(mh.hin_cd = ':chk02')then(m.mng1_flg)else(0)end) as chk02
, max(case when(mh.hin_cd = ':chk03')then(m.mng1_flg)else(0)end) as chk03
, max(case when(mh.hin_cd = ':chk04')then(m.mng1_flg)else(0)end) as chk04
, max(case when(mh.hin_cd = ':chk05')then(m.mng1_flg)else(0)end) as chk05
, max(case when(mh.hin_cd = ':chk06')then(m.mng1_flg)else(0)end) as chk06
, max(case when(mh.hin_cd = ':chk07')then(m.mng1_flg)else(0)end) as chk07
, max(case when(mh.hin_cd = ':chk08')then(m.mng1_flg)else(0)end) as chk08
, max(case when(mh.hin_cd = ':chk09')then(m.mng1_flg)else(0)end) as chk09
, max(case when(mh.hin_cd = ':chk10')then(m.mng1_flg)else(0)end) as chk10
, max(case when(mh.hin_cd = ':chk11')then(m.mng1_flg)else(0)end) as chk11
, max(case when(mh.hin_cd = ':chk12')then(m.mng1_flg)else(0)end) as chk12
, max(case when(mh.hin_cd = ':chk13')then(m.mng1_flg)else(0)end) as chk13
, max(case when(mh.hin_cd = ':chk14')then(m.mng1_flg)else(0)end) as chk14
, max(case when(mh.hin_cd = ':chk15')then(m.mng1_flg)else(0)end) as chk15
, max(case when(mh.hin_cd = ':chk16')then(m.mng1_flg)else(0)end) as chk16
, max(case when(mh.hin_cd = ':chk17')then(m.mng1_flg)else(0)end) as chk17
, max(case when(mh.hin_cd = ':chk18')then(m.mng1_flg)else(0)end) as chk18
, max(case when(mh.hin_cd = ':chk19')then(m.mng1_flg)else(0)end) as chk19
, max(case when(mh.hin_cd = ':chk20')then(m.mng1_flg)else(0)end) as chk20
, max(case when(mh.hin_cd = ':chk21')then(m.mng1_flg)else(0)end) as chk21
, max(case when(mh.hin_cd = ':chk22')then(m.mng1_flg)else(0)end) as chk22
, max(case when(mh.hin_cd = ':chk23')then(m.mng1_flg)else(0)end) as chk23
, max(case when(mh.hin_cd = ':chk24')then(m.mng1_flg)else(0)end) as chk24
, max(case when(mh.hin_cd = ':chk25')then(m.mng1_flg)else(0)end) as chk25
, max(case when(mh.hin_cd = ':chk26')then(m.mng1_flg)else(0)end) as chk26
, max(case when(mh.hin_cd = ':chk27')then(m.mng1_flg)else(0)end) as chk27
, max(case when(mh.hin_cd = ':chk28')then(m.mng1_flg)else(0)end) as chk28
, max(case when(mh.hin_cd = ':chk29')then(m.mng1_flg)else(0)end) as chk29
, max(case when(mh.hin_cd = ':chk30')then(m.mng1_flg)else(0)end) as chk30
, max(case when(mh.hin_cd = ':chk31')then(m.mng1_flg)else(0)end) as chk31
, max(case when(mh.hin_cd = ':chk32')then(m.mng1_flg)else(0)end) as chk32
, max(case when(mh.hin_cd = ':chk33')then(m.mng1_flg)else(0)end) as chk33
, max(case when(mh.hin_cd = ':chk34')then(m.mng1_flg)else(0)end) as chk34
, max(case when(mh.hin_cd = ':chk35')then(m.mng1_flg)else(0)end) as chk35
, max(case when(mh.hin_cd = ':chk36')then(m.mng1_flg)else(0)end) as chk36
, max(case when(mh.hin_cd = ':chk37')then(m.mng1_flg)else(0)end) as chk37
, max(case when(mh.hin_cd = ':chk38')then(m.mng1_flg)else(0)end) as chk38
, max(case when(mh.hin_cd = ':chk39')then(m.mng1_flg)else(0)end) as chk39
, max(case when(mh.hin_cd = ':chk40')then(m.mng1_flg)else(0)end) as chk40
from m_hanyo h26
left join m_hin mh on (mh.dhin_cd = ':hin_cd')
left join m_hin_class m on (m.hin_cd = mh.hin_cd and m.class_id = ':class_id' and m.hin_class = h26.han_name)
where h26.mst_kbn = '26'
and h26.koumoku6 = '1'
group by 
  h26.han_cd
, h26.han_name
, h26.sort_key
order by sort_key, han_cd, han_name

[deleteHinClass]
delete from m_hin_class
where hin_cd in (select hin_cd from m_hin where dhin_cd = ':hin_cd')
and class_id = ':class_id'
and hin_class = ':hin_class'
;
delete from m_hin_class
where hin_cd in (select hin_cd from m_hin where dhin_cd = ':hin_cd')
and class_id = ':class_id'
and hin_class in (select h26.koumoku7 from m_hanyo h26 where h26.mst_kbn = '26' and h26.han_name = ':hin_class' and h26.koumoku6 = '1' and h26.koumoku7 != '')
;

[insertHinClass]
insert into m_hin_class (
  hin_cd
, class_id
, hin_class
, mng1_flg
, del_flg
, cre_id
, cre_time
, upd_id
, upd_time
) values (
  ':c_hin_cd'
, ':class_id'
, ':hin_class'
, 1 --mng1_flg
, 0 --del_flg
, ':login_id' --cre_id
, now() --cre_time
, ':login_id' --upd_id
, now() --upd_time
)

[doUpdate]
select fnc_update_basv1014(':hin_cd', ':class_id', ':hin_class', ':login_id')




[updateDelFlg]
update m_hanyo set
	del_flg = 1
	,upd_id = ':id_user'
	,upd_time = now()
where mst_kbn = ':mst_kbn'
	and han_cd = ':han_cd'
;

[deleteRecord]
delete from m_hanyo
where mst_kbn = ':mst_kbn'

[insertRecord]
insert into m_hanyo
(
mst_kbn
, han_cd
, han_name
, koumoku1
, koumoku2
, koumoku3
, koumoku4
, koumoku5
, koumoku6
, koumoku7
, koumoku8
, koumoku9
, sort_key
, del_flg
, cre_id
, cre_time
, upd_id,
upd_time
)
values
	(
	':mst_kbn'
	, ':han_cd'
	, ':han_name'
	, ':koumoku1'
	, ':koumoku2'
	, ':koumoku3'
	, ':koumoku4'
	, ':koumoku5'
	, ':koumoku6'
	, ':koumoku7'
	, ':koumoku8'
	, ':koumoku9'
	, ':sort_key'
	, '0'
	, ''
	, 'now()'
	, ''
	, 'now()'
	);

