[load_grdList]
select
  s.den_no
, s.row_no
, s.sethin_row_no
, s.hin_cd
, s.hin_nm
, s.suryo
, null as tanka
, null as kingaku
, um.hin_cd as ohin_cd
, um.hin_nm as ohin_nm
, um.suryo as uri_su
, uh.syori_ymd
, uh.tok_cd
, uh.tok_nm
, uh.jucyu_no
, null as sir_no
, s.den_no||'-'||s.row_no as den_key
from t_syuko_plan s
inner join t_uri_m um on (um.den_no = s.den_no and um.row_no = s.row_no)
inner join t_uri uh on (uh.den_no = um.den_no)
where COALESCE(um.syuko_flg,0) = 0
and ((uh.jucyu_no = fnc_to_number(':jucyu_no')) or ('' = ':jucyu_no'))
and ((uh.den_no = fnc_to_number(':den_no')) or ('' = ':den_no'))
and (('' = ':syori_ymd_fr') or (uh.syori_ymd >= ':syori_ymd_fr'))
and (('' = ':syori_ymd_to') or (uh.syori_ymd <= ':syori_ymd_to'))
and (('' = ':tok_cd') or (uh.tok_cd = ':tok_cd'))
and ((uh.tok_nm like '%:tok_nm%') or ('' = ':tok_nm'))
and (':nk_cond' != '1')
union all
select
  s.uri_no as den_no
, s.uri_row_no as row_no
, s.den_no as sethin_row_no
, s.hin_cd
, s.hin_nm
, s.suryo
, s.tanka
, s.kingaku
, s.ohin_cd
, s.ohin_nm
, um.suryo as uri_su
, s.syori_ymd
, uh.tok_cd
, uh.tok_nm
, s.jucyu_no
, s.sir_no
, s.uri_no||'-'||s.uri_row_no as den_key
from t_syuko s
left join t_uri_m um on (um.den_no = s.uri_no and um.row_no = s.uri_row_no)
left join t_uri uh on (uh.den_no = um.den_no)
where 1 = 1
and ((s.jucyu_no = fnc_to_number(':jucyu_no')) or ('' = ':jucyu_no'))
and ((s.uri_no = fnc_to_number(':den_no')) or ('' = ':den_no'))
and (('' = ':syori_ymd_fr') or (s.syori_ymd >= ':syori_ymd_fr'))
and (('' = ':syori_ymd_to') or (s.syori_ymd <= ':syori_ymd_to'))
and (('' = ':tok_cd') or (uh.tok_cd = ':tok_cd'))
and ((uh.tok_nm like '%:tok_nm%') or ('' = ':tok_nm'))
and (':nk_cond' != '0')

order by syori_ymd, den_no, row_no, sethin_row_no




