[maxcd] select MAX(tokui_cd +1 ) from m_tokui; [load_grdList] select m.tokui_cd as tokui_cd, cast(m.group_cd as integer) as group_cd, m.tokui_nm, m.tokui_nm2, m.tokui_kn, case when m.post_no = '' then '' else left(m.post_no,3)||'-'||right(m.post_no,4) end as post_no, --left(m.post_no,3)||'-'||right(m.post_no,4) as post_no, m.adrres1, m.adrres2, m.adrres3, m.tel_no, m.fax_no, sh.shain_nm as mtan_cd, sh2.shain_nm as mtan_cd2, m.shime, m.biko from m_tokui m left join m_shain sh on m.mtan_cd = sh.shain_cd left join m_shain sh2 on m.mtan_cd2 = sh2.shain_cd where 1=1 and (cast(tokui_cd as varchar) = ':tokui_cd' or '' = ':tokui_cd' ) and (m.group_cd = ':group_cd' or '' = ':group_cd') and (m.tokui_nm like '%:tokui_nm%' or '' = ':tokui_nm') and (m.tokui_nm2 like '%:tokui_nm2%' or '' = ':tokui_nm2') and (m.tokui_kn like '%:tokui_kn%' or '' = ':tokui_kn') and (m.tel_no = ':tel_no' or '' = ':tel_no') and ((cast(mtan_cd as varchar) = ':mtan_cd' ) or ( '' = ':mtan_cd') or (cast(mtan_cd2 as varchar) = ':mtan_cd' ) or ( '' = ':mtan_cd')) and (m.shime = ':shime' or '' = ':shime') --and(('' = ':tokui_cd') or (tokui_cd like ':tokui_cd%')) --and (('' = ':tokui_nm') or (tokui_nm like '%:tokui_nm%')) --and (('' = ':tokui_kn') or (tokui_kn like ':tokui_kn%')) --and (('' = ':mtan_cd') or (mtan_cd like ':mtan_cd%')) --and (('' = ':sime') or (sime like ':sime%')) --and (('' = ':old') or (cast(date_part('year',age(current_date,birth))as char(3)) = ':old')) --and (('' = ':birth') or (cast(birth as char(10)) = 'birth%')) --and (('' = ':gender') or (case sex when '1' then 'j' when '2' then '' end like ':gender%')) order by group_cd,tokui_cd; [load_grdList1] select cast(m.tokui_cd as integer) as tokui_cd, cast(m.group_cd as integer) as group_cd, m.tokui_nm, m.tokui_nm2, m.tokui_kn, left(m.post_no,3)||'-'||right(m.post_no,4) as post_no, m.adrres1, m.adrres2, m.adrres3, m.tel_no, m.fax_no, sh.shain_nm as mtan_cd, sh2.shain_nm as mtan_cd2, m.shime, m.biko from m_tokui m left join m_shain sh on m.mtan_cd = sh.shain_cd left join m_shain sh2 on m.mtan_cd2 = sh2.shain_cd where 1=1 order by group_cd,tokui_cd; [load_grdList3] select m.tokui_cd, m.group_cd, m.tokui_nm, m.tokui_nm2, --m.post_no, left(m.post_no,3)||'-'||right(m.post_no,4) as post_no, m.adrres1, m.adrres2, m.adrres3, m.tel_no, tan.shain_nm as mtan_cd, sh.shain_nm as mtan_cd2, m.biko, m.tokui_kn from m_tokui m left join m_shain tan on tan.shain_cd = m.mtan_cd left join m_shain sh on sh.shain_cd = m.mtan_cd2 where (m.tokui_cd = ':tokui_cd' or '' = ':tokui_cd') and (m.group_cd = ':group_cd' or '' = ':group_cd') and (mtan_cd = ':mtan_cd' or '' = ':mtan_cd') order by m.group_cd,m.tokui_cd ; [existtokui] select 1 from m_tokui where tokui_cd = ':tokui_cd'