[load_grdList]
select han_cd, han_name
,(case coalesce(a[1],'') when ''then 0 else 1 end) as chg_1
,(case coalesce(a[2],'') when ''then 0 else 1 end) as chg_2
,(case coalesce(a[3],'') when ''then 0 else 1 end) as chg_3
,(case coalesce(a[4],'') when ''then 0 else 1 end) as chg_4
,(case coalesce(a[5],'') when ''then 0 else 1 end) as chg_5
,(case coalesce(a[6],'') when ''then 0 else 1 end) as chg_6
,(case coalesce(a[7],'') when ''then 0 else 1 end) as chg_7
,(case coalesce(a[8],'') when ''then 0 else 1 end) as chg_8
,(case coalesce(a[9],'') when ''then 0 else 1 end) as chg_9
,(case coalesce(a[10],'') when ''then 0 else 1 end) as chg_10
,(case coalesce(a[11],'') when ''then 0 else 1 end) as chg_11
,(case coalesce(a[12],'') when ''then 0 else 1 end) as chg_12
,(case coalesce(a[13],'') when ''then 0 else 1 end) as chg_13
,(case coalesce(a[14],'') when ''then 0 else 1 end) as chg_14
,(case coalesce(a[15],'') when ''then 0 else 1 end) as chg_15
,(case coalesce(a[16],'') when ''then 0 else 1 end) as chg_16
,(case coalesce(a[17],'') when ''then 0 else 1 end) as chg_17
,(case coalesce(a[18],'') when ''then 0 else 1 end) as chg_18
,(case coalesce(a[19],'') when ''then 0 else 1 end) as chg_19
,(case coalesce(a[20],'') when ''then 0 else 1 end) as chg_20
from (select han_cd, han_name,koumoku5,regexp_split_to_array(koumoku5,',') as A from m_hanyo where mst_kbn = '21') v
where 1 = 1
and ((':kbn' != '') and (1 = ':kbn'))
union all
select han_cd, han_name
,(case coalesce(a[1],'') when ''then 0 else 1 end) as chg_1
,(case coalesce(a[2],'') when ''then 0 else 1 end) as chg_2
,(case coalesce(a[3],'') when ''then 0 else 1 end) as chg_3
,(case coalesce(a[4],'') when ''then 0 else 1 end) as chg_4
,(case coalesce(a[5],'') when ''then 0 else 1 end) as chg_5
,(case coalesce(a[6],'') when ''then 0 else 1 end) as chg_6
,(case coalesce(a[7],'') when ''then 0 else 1 end) as chg_7
,(case coalesce(a[8],'') when ''then 0 else 1 end) as chg_8
,(case coalesce(a[9],'') when ''then 0 else 1 end) as chg_9
,(case coalesce(a[10],'') when ''then 0 else 1 end) as chg_10
,(case coalesce(a[11],'') when ''then 0 else 1 end) as chg_11
,(case coalesce(a[12],'') when ''then 0 else 1 end) as chg_12
,(case coalesce(a[13],'') when ''then 0 else 1 end) as chg_13
,(case coalesce(a[14],'') when ''then 0 else 1 end) as chg_14
,(case coalesce(a[15],'') when ''then 0 else 1 end) as chg_15
,(case coalesce(a[16],'') when ''then 0 else 1 end) as chg_16
,(case coalesce(a[17],'') when ''then 0 else 1 end) as chg_17
,(case coalesce(a[18],'') when ''then 0 else 1 end) as chg_18
,(case coalesce(a[19],'') when ''then 0 else 1 end) as chg_19
,(case coalesce(a[20],'') when ''then 0 else 1 end) as chg_20
from (select han_cd, han_name,koumoku9,regexp_split_to_array(koumoku9,',') as A from m_hanyo where mst_kbn = '21') v
where 1 = 1
and ((':kbn' != '') and (2 = ':kbn'))
union all
select han_cd, han_name
,(case coalesce(a[1],'') when ''then 0 else 1 end) as chg_1
,(case coalesce(a[2],'') when ''then 0 else 1 end) as chg_2
,(case coalesce(a[3],'') when ''then 0 else 1 end) as chg_3
,(case coalesce(a[4],'') when ''then 0 else 1 end) as chg_4
,(case coalesce(a[5],'') when ''then 0 else 1 end) as chg_5
,(case coalesce(a[6],'') when ''then 0 else 1 end) as chg_6
,(case coalesce(a[7],'') when ''then 0 else 1 end) as chg_7
,(case coalesce(a[8],'') when ''then 0 else 1 end) as chg_8
,(case coalesce(a[9],'') when ''then 0 else 1 end) as chg_9
,(case coalesce(a[10],'') when ''then 0 else 1 end) as chg_10
,(case coalesce(a[11],'') when ''then 0 else 1 end) as chg_11
,(case coalesce(a[12],'') when ''then 0 else 1 end) as chg_12
,(case coalesce(a[13],'') when ''then 0 else 1 end) as chg_13
,(case coalesce(a[14],'') when ''then 0 else 1 end) as chg_14
,(case coalesce(a[15],'') when ''then 0 else 1 end) as chg_15
,(case coalesce(a[16],'') when ''then 0 else 1 end) as chg_16
,(case coalesce(a[17],'') when ''then 0 else 1 end) as chg_17
,(case coalesce(a[18],'') when ''then 0 else 1 end) as chg_18
,(case coalesce(a[19],'') when ''then 0 else 1 end) as chg_19
,(case coalesce(a[20],'') when ''then 0 else 1 end) as chg_20
from (select han_cd, han_name,koumoku6,regexp_split_to_array(koumoku6,',') as A from m_hanyo where mst_kbn = '21') v
where 1 = 1
and ((':kbn' != '') and (3 = ':kbn'))
order by han_cd
;

[getKouteiFields]
select han_name from m_hanyo
where mst_kbn = ':_mst_kbn'
order by cast(han_cd as int)

[updateKoutei]
update m_hanyo set :_koumoku = ':koumoku_s'
where mst_kbn = '21'
and han_cd = ':_han_cd'
;

[get_tanto_list]
select * from m_hanyo
--where mst_kbn = '24'
where mst_kbn = '20'
and del_flg = 0
order by mst_kbn, sort_key, han_cd
;

[deleteRecord]
delete from m_hanyo
where mst_kbn = '21'
;

[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()'
	);

[updateAnken]
update t_anken_m am set
  check_kbn = (select max(v.check_kbn) from v_m_koutei v where v.koutei_cd = am.koutei_cd)
, koutei_filter = (select max(v.koutei_filter) from v_m_koutei v where v.koutei_cd = am.koutei_cd)
, alert_kbn = (select max(v.alert_kbn) from v_m_koutei v where v.koutei_cd = am.koutei_cd)
where am.anken_cd in (
select ah.anken_cd
from t_anken ah
inner join m_hanyo h1 on (h1.mst_kbn = '90' and h1.han_cd = 'sedai_cd')
where ah.sedai_cd = h1.koumoku1
)




