[updateOriginal]
select fnc_update_basv1017(:s_id);


[load_grdList]
SELECT hin_cd,hin_nm,hin_rnm,color_cd,sort_key,file_name,dhin_cd
FROM w_hin_atch 
WHERE s_id = :s_id
AND dhin_cd = ':dhin_cd'
ORDER BY sort_key
;

[getDocs]
SELECT file_name,file_image 
FROM w_hin_atch 
WHERE s_id = :s_id
AND hin_cd = ':pHinCd'
;

[getInitCd]
SELECT v.han_cd, v.han_name
From v_hanyo_all v
LEFT JOIN m_hin m on v.han_cd = m.dhin_cd
WHERE mst_kbn = 'dhin_cd'
AND (han_cd =':dhin_cd' or ''=':dhin_cd')
ORDER BY m.sort_key, m.dhin_cd limit 1
;

[deleteWork]
DELETE FROM w_hin_atch WHERE s_id = :s_id;

[createWorkAtch]
DELETE FROM w_hin_atch WHERE s_id = :s_id;

INSERT INTO w_hin_atch
(s_id, hin_cd, hin_nm, hin_rnm, file_name, file_image, color_cd, sort_key, dhin_cd, del_flg, cre_id, cre_time, upd_id, upd_time)
select :s_id, m.hin_cd, m.hin_nm, m.hin_rnm, ha.file_name, ha.file_image, m.color_cd, m.sort_key, m.dhin_cd, m.del_flg, m.cre_id, m.cre_time, m.upd_id, m.upd_time
from m_hin m
left join t_hin_atch ha on m.hin_cd = ha.hin_cd and ha.row_no = 0
where m.del_flg = 0
and m.cat_cd = '12'
--and m.dhin_cd = ':dhin_cd'
--and m.hin_cd != ':dhin_cd' --TODO
and m.dhin_cd != m.hin_cd --TODO
order by m.hin_cd
;

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