[load_grdList] select case t1.DT_BUNDLE when null then 0 else 1 end chk ,t1.CD_CUSTOMER ,t1.NAME_CUSTOMER ,(case(t1.DUE_CUSTOMER1) when(':dtsDay') then(t1.DUE_CUSTOMER1) else(case(t1.DUE_CUSTOMER2) when(':dtsDay') then(t1.DUE_CUSTOMER2) else(case(t1.DUE_CUSTOMER3) when(':dtsDay') then(t1.DUE_CUSTOMER3) end) end) end) DUE_CUSTOMER ,(case when(t1.DT_BUNDLE is null) then(null) else('締完(' || t1.state || ')') end) state ,(case when(t1.ZEN_BUNDLE is null) then('1000-01-01') else(t1.ZEN_BUNDLE) end) ZEN_BUNDLE ,case when t1.DT_BUNDLE = null then '1' when t1.DT_BUNDLE > to_date(':dtsYear' || lpad(':dtsMonth', 2, '0') || lpad(':dtsDay', 2, '0')) then '0' else '1' end FLG_BUNDLE from ( select mc.CD_CUSTOMER ,mc.NAME_CUSTOMER ,mc.DUE_CUSTOMER1 ,mc.DUE_CUSTOMER2 ,mc.DUE_CUSTOMER3 ,tkb.DT_BUNDLE --#24303 2022.06.18 MOD STT -- ,substr(to_date(tkb.DT_BUNDLE),1,10) state ,to_char(tkb.DT_BUNDLE, 'YYYY-MM-DD') state --#24303 2022.06.18 MOD END ,tkb2.ZEN_BUNDLE from ( select CD_CUSTOMER ,NAME_CUSTOMER ,(case(DUE_CUSTOMER1) when('99') then(substr(to_char(last_day(to_date(':dtsYear' || lpad(':dtsMonth', 2, '0') || '01')), 'yyyymmdd'), 7, 2)) else(DUE_CUSTOMER1) end) DUE_CUSTOMER1 ,(case(DUE_CUSTOMER2) when('99') then(substr(to_char(last_day(to_date(':dtsYear' || lpad(':dtsMonth', 2, '0') || '01')), 'yyyymmdd'), 7, 2)) else(DUE_CUSTOMER2) end) DUE_CUSTOMER2 ,(case(DUE_CUSTOMER3) when('99') then(substr(to_char(last_day(to_date(':dtsYear' || lpad(':dtsMonth', 2, '0') || '01')), 'yyyymmdd'), 7, 2)) else(DUE_CUSTOMER3) end) DUE_CUSTOMER3 from M_CUSTOMER where DT_START <= to_date(':dtsYear' || lpad(':dtsMonth', 2, '0') || lpad(':dtsDay', 2, '0')) and DT_END > to_date(':dtsYear' || lpad(':dtsMonth', 2, '0') || lpad(':dtsDay', 2, '0')) and FLG_DELETE = 0 ) mc left join ( select CD_CUSTOMER ,max(DT_BUNDLE) DT_BUNDLE from T_KANRI_BUNDLE where DT_BUNDLE >= to_Date(':dtsYear' || lpad(':dtsMonth', 2, '0') || lpad(':dtsDay', 2, '0')) and FLG_DELETE = 0 group by CD_CUSTOMER ) tkb on mc.CD_CUSTOMER = tkb.CD_CUSTOMER left join ( select CD_CUSTOMER ,max(DT_BUNDLE) ZEN_BUNDLE from T_KANRI_BUNDLE where DT_BUNDLE < to_Date(':dtsYear' || lpad(':dtsMonth', 2, '0') || lpad(':dtsDay', 2, '0')) and FLG_DELETE = 0 group by CD_CUSTOMER ) tkb2 on mc.CD_CUSTOMER = tkb2.CD_CUSTOMER where ((mc.DUE_CUSTOMER1 = ':dtsDay') or(mc.DUE_CUSTOMER2 = ':dtsDay') or(mc.DUE_CUSTOMER3 = ':dtsDay')) ) t1 --#24303 2022.06.18 MOD STT --where ((':cdCustomer' is null)or(t1.CD_CUSTOMER = ':cdCustomer')) where ((':cdCustomer' = '') or(t1.CD_CUSTOMER = to_number(':cdCustomer'))) --#24303 2022.06.18 MOD END order by t1.CD_CUSTOMER [updBundle] --#24445 2022.06.28 MOD STT --select PRC_updBundle(':flg_bundle', :dtsYear, :dtsMonth, :dtsDay, :cd_customer, ':zen_bundle', ':login_id') select PRC_updBundle(':flg_bundle', :dtsYear, :dtsMonth, :dtsDay, :cd_customer, to_char(cast(':zen_bundle' as date), 'YYYYMMDD'), ':login_id') --#24445 2022.06.28 MOD END [__updBundle] -- declare -- begin -- if ':flg_bundle' = '0' then -- return; -- end if; -- delete from T_KANRI_BUNDLE -- where DTS_YEAR = ':dtsYear' -- and DTS_MONTH = ':dtsMonth' -- and DTS_DAY = ':dtsDay' -- and CD_CUSTOMER = ':cd_customer'; -- delete from T_SEIKYU_TBL -- where DT_SEIKYU = to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) -- and CD_CUSTOMER = ':cd_customer'; -- delete from T_SEIKYU_H -- where DT_SEIKYU = to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) -- and CD_CUSTOMER = ':cd_customer'; -- insert into T_KANRI_BUNDLE -- (CD_CUSTOMER -- , DT_BUNDLE -- , DTS_YEAR -- , DTS_MONTH -- , DTS_DAY -- , ZEN_BUNDLE -- , FLG_DELETE -- , ID_REGIST -- , ID_UPDATE -- , ID_DELETE -- , DT_REGIST -- , DT_UPDATE -- , DT_DELETE) -- values -- (':cd_customer' -- , to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) -- , ':dtsYear' -- , ':dtsMonth' -- , ':dtsDay' -- , to_date(':zen_bundle') -- , 0 -- , ':login_id' -- , null -- , null -- , sysdate -- , null -- , null) -- ; -- insert into T_SEIKYU_TBL -- (CD_CUSTOMER -- , DT_SEIKYU -- , NO_LINE -- , DT_SALE -- , MONEY_SEIKYU_KEY -- , RATE_TAX -- , TAX -- , CD_PRODUCT -- , NAME_PRODUCT -- , CNT_DATA -- , UNIT_PRICE_SALE -- , MONEY_SALE -- , MONEY_FRACTION_ADJUST -- , DIV_SALE -- , NOTE -- , FLG_FCS -- , FLG_DELETE -- , ID_REGIST -- , DT_REGIST) -- select -- t1.CD_CUSTOMER -- ,t1.DT_SEIKYU -- ,rownum NO_LINE -- ,t1.DT_SALE -- ,t1.MONEY_SEIKYU_KEY -- ,t1.RATE_TAX -- ,t1.TAX -- ,t1.CD_PRODUCT -- ,t1.NAME_PRODUCT -- ,t1.WEIGHT_SALE -- ,t1.UNIT_PRICE_SALE -- ,t1.MONEY_SALE -- ,t1.MONEY_FRACTION_ADJUST -- ,t1.DIV_SALE -- --,t1.NOTE -- ,case when t1.FLG_OUT_DER=1 then t1.NAME_DERIVERY || '様分' else '' end -- || case when t1.FLG_OUT_DER=1 and (trim(t1.NOTE)<>'' or t1.NOTE is not null) then '、' else '' end -- || t1.NOTE as NOTE -- ,t1.FLG_FCS -- ,0 FLG_DELETE -- ,':login_id' ID_REGIST -- ,sysdate DT_REGIST -- from -- (select -- ts.CD_CUSTOMER -- ,to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) DT_SEIKYU -- ,ts.DT_SALE -- ,(select sum(decode(TOTAL_MONEY,null,0,TOTAL_MONEY)) from T_SALE where DT_SALE > to_date(':zen_bundle') and DT_SALE <= to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) and CD_CUSTOMER = ':cd_customer') MONEY_SEIKYU_KEY -- --2016.05.23 K.Takahashi 消費税率をコントロールマスタから取得する。 -- -- ,ts.RATE_TAX -- ,(SELECT NEW_TAX FROM M_CONTROL CTRL WHERE CTRL.TAX_START_DAY = ( SELECT MAX(CTRL2.TAX_START_DAY) FROM M_CONTROL CTRL2 WHERE CTRL2.TAX_START_DAY <= to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) ) ) as RATE_TAX -- ,ts.TAX -- ,ts.CD_PRODUCT -- ,mp.NAME_PRODUCT -- ,ts.WEIGHT_SALE -- ,ts.UNIT_PRICE_SALE -- ,ts.MONEY_SALE -- ,ts.MONEY_FRACTION_ADJUST -- ,ts.DIV_SALE -- ,ts.NOTE -- ,ts.FLG_FCS -- ,md.NAME_DERIVERY -- ,mc.FLG_OUT_DER -- from T_SALE ts -- left join M_PRODUCT mp -- on ts.CD_PRODUCT = mp.CD_PRODUCT -- left join M_DERIVERY md -- on ts.CD_DERIVERY = md.CD_DERIVERY and md.DT_START <= ts.DT_SALE and ts.DT_SALE <= md.DT_END -- left join M_CUSTOMER mc -- on ts.CD_CUSTOMER = mc.CD_CUSTOMER and mc.DT_START <= to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) and to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) <= mc.DT_END -- where DT_SALE > to_date(':zen_bundle') -- and DT_SALE <= to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) -- and ts.CD_CUSTOMER = ':cd_customer' -- and ts.FLG_DELETE = 0 -- --20151104 matsui -- and mp.FLG_DELETE = 0 -- --20151104 matsui -- order by DT_SALE, CD_PRODUCT) t1 -- ; -- --20160419谷口 T_SEIKYU_TBLの処理の後なのでT_SEIKYU_TBLを使用 -- insert into T_SEIKYU_H -- (CD_CUSTOMER, DT_SEIKYU, RATE_TAX, MONEY_SALE, FLG_DELETE, ID_REGIST, DT_REGIST) -- select -- CD_CUSTOMER -- , DT_SEIKYU -- , RATE_TAX *100 -- , sum(MONEY_SALE) -- ,0 FLG_DELETE -- ,':login_id' ID_REGIST -- ,sysdate DT_REGIST -- from ( -- select -- CD_CUSTOMER -- , NAME_CUSTOMER || ' 御中' as NAME_CUSTOMER -- , DT_SEIKYU -- , DTS_Y -- , DTS_M -- , DTS_D -- , MONEY_SEIKYU_KEY -- , RATE_TAX -- , TAX -- , CD_PRODUCT -- , decode(FLG_FCS,1,NAME_PRODUCT || ' (FSCリサイクルクレジット)',NAME_PRODUCT) NAME_PRODUCT -- , CNT_DATA -- , UNIT_PRICE_SALE -- , MONEY_SALE -- , NOW -- , decode(FLG_FCS,null,NOTE,decode(FLG_FCS,0,NOTE, NOTE || 'FSC製品')) NOTE -- , FLG_FCS -- , decode(FLG_FCS,null,'',decode(FLG_FCS,0,'', 'COC認証番号 SA-COC-004068')) FSC -- , ODR_DTS_Y -- , ODR_DTS_M -- , ODR_DTS_D -- from -- (select ts.CD_CUSTOMER -- , mc.NAME_CUSTOMER -- , ts.DT_SEIKYU -- , to_char(to_number(to_char(ts.DT_SALE, 'yyyy'))) DTS_Y -- , to_char(to_number(to_char(ts.DT_SALE, 'mm'))) DTS_M -- , to_char(to_number(to_char(ts.DT_SALE, 'dd'))) DTS_D -- , ts.MONEY_SEIKYU_KEY -- , to_char(ts.RATE_TAX/100,'0.00') RATE_TAX -- , ts.TAX -- , ts.CD_PRODUCT -- , decode(ts.DIV_SALE,1,'値引き',ts.NAME_PRODUCT) NAME_PRODUCT -- , ts.CNT_DATA -- , decode(ts.MONEY_FRACTION_ADJUST,null,ts.UNIT_PRICE_SALE,0,ts.UNIT_PRICE_SALE,null) UNIT_PRICE_SALE -- , ts.MONEY_SALE -- , SYSDATE NOW -- , ts.NOTE -- , ts.FLG_FCS -- , to_number(to_char(ts.DT_SALE, 'yyyy')) ODR_DTS_Y -- , to_number(to_char(ts.DT_SALE, 'mm')) ODR_DTS_M -- , to_number(to_char(ts.DT_SALE, 'dd')) ODR_DTS_D -- from T_SEIKYU_TBL ts -- left join M_CUSTOMER mc -- on ts.CD_CUSTOMER = mc.CD_CUSTOMER and mc.DT_START <= to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) and to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) <= mc.DT_END -- where ts.DT_SEIKYU = to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) -- and ts.FLG_DELETE = 0 -- and ts.CD_CUSTOMER <> 1 -- and mc.FLG_DELETE = 0 -- union all -- select -- t1.CD_CUSTOMER -- , t1.NAME_CUSTOMER -- , t1.DT_SEIKYU -- , t1.DTS_Y -- , t1.DTS_M -- , t1.DTS_D -- , (select sum(MONEY_SEIKYU_KEY) from (select tst.CD_CUSTOMER,trunc(sum(tst.CNT_DATA) * tst.UNIT_PRICE_SALE) MONEY_SEIKYU_KEY from T_SEIKYU_TBL tst left join M_CUSTOMER m_c on tst.CD_CUSTOMER = m_c.CD_CUSTOMER where tst.DT_SEIKYU = to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) and tst.FLG_DELETE = 0 and tst.CD_CUSTOMER = 1 group by tst.CD_CUSTOMER,tst.UNIT_PRICE_SALE)) MONEY_SEIKYU_KEY -- , t1.RATE_TAX -- , sum(t1.TAX) TAX -- , t1.CD_PRODUCT -- , t1. NAME_PRODUCT -- , sum(t1.CNT_DATA) CNT_DATA -- , t1. UNIT_PRICE_SALE -- , trunc(sum(t1.CNT_DATA) * t1. UNIT_PRICE_SALE) MONEY_SALE -- , t1. NOW -- , t1.NOTE -- , t1.FLG_FCS -- ,ODR_DTS_Y -- ,ODR_DTS_M -- ,ODR_DTS_D -- from -- (select ts.CD_CUSTOMER -- , mc.NAME_CUSTOMER -- , ts.DT_SEIKYU -- , ts.NO_LINE -- , ts.DT_SALE -- , to_char(to_number(to_char(ts.DT_SALE, 'yyyy'))) DTS_Y -- , to_char(to_number(to_char(ts.DT_SALE, 'mm'))) DTS_M -- , case when to_number(substr(to_char(ts.DT_SALE,'yyyymmdd'),7,2)) < 21 then '1〜20' -- else '21〜' || to_char(last_day(ts.DT_SALE),'dd') end DTS_D -- , ts.MONEY_SEIKYU_KEY -- , to_char(ts.RATE_TAX/100,'0.00') RATE_TAX -- , ts.TAX -- , ts.CD_PRODUCT -- , decode(ts.DIV_SALE,1,'値引き',ts.NAME_PRODUCT) NAME_PRODUCT -- , ts.CNT_DATA -- , decode(ts.MONEY_FRACTION_ADJUST,null,ts.UNIT_PRICE_SALE,0,ts.UNIT_PRICE_SALE,null) UNIT_PRICE_SALE -- , ts.MONEY_SALE -- , SYSDATE NOW -- , ts.NOTE -- , ts.FLG_FCS -- , to_number(to_char(ts.DT_SALE, 'yyyy')) ODR_DTS_Y -- , to_number(to_char(ts.DT_SALE, 'mm')) ODR_DTS_M -- , case when to_number(substr(to_char(ts.DT_SALE,'yyyymmdd'),7,2)) < 21 then 1 -- else 2 end ODR_DTS_D -- from T_SEIKYU_TBL ts -- left join M_CUSTOMER mc -- on ts.CD_CUSTOMER = mc.CD_CUSTOMER and mc.DT_START <= to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) and to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) <= mc.DT_END -- where ts.DT_SEIKYU = to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) -- and ts.FLG_DELETE = 0 -- and ts.CD_CUSTOMER = 1 -- and mc.FLG_DELETE = 0 -- ) t1 -- group by t1.DTS_Y, t1.DTS_M, t1.DTS_D, t1.CD_PRODUCT, t1.NAME_PRODUCT, t1.CD_CUSTOMER, t1.NAME_CUSTOMER, t1.DT_SEIKYU, t1.RATE_TAX, t1.UNIT_PRICE_SALE, t1.NOW, t1.NOTE, t1.MONEY_SEIKYU_KEY, t1.FLG_FCS -- ,ODR_DTS_Y -- ,ODR_DTS_M -- ,ODR_DTS_D -- )ts -- --where ((':cd_customer' is null)or(CD_CUSTOMER = ':cd_customer')) -- where CD_CUSTOMER = ':cd_customer' -- order by CD_CUSTOMER, NAME_CUSTOMER, ODR_DTS_Y, ODR_DTS_M, ODR_DTS_D, DT_SEIKYU, CD_PRODUCT, NAME_PRODUCT, RATE_TAX -- ) w1 -- group by CD_CUSTOMER, DT_SEIKYU, RATE_TAX --, FLG_DELETE, ID_REGIST ,DT_REGIST -- --having DT_SEIKYU = to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) -- -- and ((':cd_customer' is null)or(CD_CUSTOMER = ':cd_customer')) -- ; -- update T_SEIKYU_H tsh set -- tax=round(MONEY_SALE*RATE_TAX/100), -- MONEY_SEIKYU_KEY=round(MONEY_SALE*(1+RATE_TAX/100)) -- where CD_CUSTOMER<>'1' -- --and ((':cd_customer' is null)or(CD_CUSTOMER = ':cd_customer')) -- and CD_CUSTOMER = ':cd_customer' -- and DT_SEIKYU = to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) -- ; -- update T_SEIKYU_H tsh set -- tax=trunc(MONEY_SALE*RATE_TAX/100), -- MONEY_SEIKYU_KEY=trunc(MONEY_SALE*(1+RATE_TAX/100)) -- where CD_CUSTOMER='1' -- --and ((':cd_customer' is null)or(CD_CUSTOMER = ':cd_customer')) -- and CD_CUSTOMER = ':cd_customer' -- and DT_SEIKYU = to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) -- ; -- end; [updSeikyu] insert into T_SEIKYU_TBL( CD_CUSTOMER ,DT_SEIKYU ,NO_LINE ,DT_SALE ,MONEY_SEIKYU_KEY ,RATE_TAX ,TAX ,CD_PRODUCT ,NAME_PRODUCT ,CNT_DATA ,UNIT_PRICE_SALE ,MONEY_SALE ,MONEY_FRACTION_ADJUST ,DIV_SALE ,NOTE ,FLG_FCS ,FLG_DELETE ,ID_REGIST ,DT_REGIST ) select t1.CD_CUSTOMER ,t1.DT_SEIKYU ,rownum NO_LINE ,t1.DT_SALE ,t1.MONEY_SEIKYU_KEY ,t1.RATE_TAX ,t1.TAX ,t1.CD_PRODUCT ,t1.NAME_PRODUCT ,t1.WEIGHT_SALE ,t1.UNIT_PRICE_SALE ,t1.MONEY_SALE ,t1.MONEY_FRACTION_ADJUST ,t1.DIV_SALE ,t1.NOTE ,t1.FLG_FCS ,0 FLG_DELETE ,':login_id' ID_REGIST ,sysdate DT_REGIST from ( select ts.CD_CUSTOMER ,to_date(':dtsYear' || lpad(':dtsMonth', 2, '0') || lpad(':dtsDay', 2, '0')) DT_SEIKYU ,ts.DT_SALE ,( select sum(decode(TOTAL_MONEY, null, 0, TOTAL_MONEY)) from T_SALE where DT_SALE > to_date(':zen_bundle') and DT_SALE <= to_date(':dtsYear' || lpad(':dtsMonth', 2, '0') || lpad(':dtsDay', 2, '0')) and CD_CUSTOMER = ':cd_customer' ) MONEY_SEIKYU_KEY ,ts.RATE_TAX ,ts.TAX ,ts.CD_PRODUCT ,mp.NAME_PRODUCT ,ts.WEIGHT_SALE ,ts.UNIT_PRICE_SALE ,ts.MONEY_SALE ,ts.MONEY_FRACTION_ADJUST ,ts.DIV_SALE ,ts.NOTE ,ts.FLG_FCS from T_SALE ts left join M_PRODUCT mp on ts.CD_PRODUCT = mp.CD_PRODUCT where DT_SALE > to_date(':zen_bundle') and DT_SALE <= to_date(':dtsYear' || lpad(':dtsMonth', 2, '0') || lpad(':dtsDay', 2, '0')) and CD_CUSTOMER = ':cd_customer' and mp.FLG_DELETE = 0 order by DT_SALE, CD_PRODUCT ) t1 [delBundle] select PRC_delBundle(':flg_bundle', :dtsYear, :dtsMonth, :dtsDay, :cd_customer) [__delBundle] -- declare -- begin -- if ':flg_bundle' = '0' then -- return; -- end if; -- delete from T_KANRI_BUNDLE -- where DTS_YEAR = ':dtsYear' -- and DTS_MONTH = ':dtsMonth' -- and DTS_DAY = ':dtsDay' -- and CD_CUSTOMER = ':cd_customer'; -- delete from T_SEIKYU_TBL -- where DT_SEIKYU = to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) -- and CD_CUSTOMER = ':cd_customer'; -- delete from T_SEIKYU_H -- where DT_SEIKYU = to_date(':dtsYear'||lpad(':dtsMonth',2,'0')||lpad(':dtsDay',2,'0')) -- and CD_CUSTOMER = ':cd_customer'; -- end; [chkExist] select CD_CUSTOMER ,DT_BUNDLE from T_KANRI_BUNDLE where DTS_YEAR = ':dtsYear' and DTS_MONTH = ':dtsMonth' and DTS_DAY = ':dtsDay' and CD_CUSTOMER = ':cd_customer' [chkExistSeikyu] select CD_CUSTOMER ,DT_SEIKYU from T_SEIKYU_TBL where DT_SEIKYU = to_date(':dtsYear' || lpad(':dtsMonth', 2, '0') || lpad(':dtsDay', 2, '0')) and CD_CUSTOMER = ':cd_customer' [deleteBundle] delete from T_KANRI_BUNDLE where DTS_YEAR = ':dtsYear' and DTS_MONTH = ':dtsMonth' and DTS_DAY = ':dtsDay' and CD_CUSTOMER = ':cd_customer' [deleteSeikyu] delete from T_SEIKYU_TBL where DT_SEIKYU = to_date(':dtsYear' || lpad(':dtsMonth', 2, '0') || lpad(':dtsDay', 2, '0')) and CD_CUSTOMER = ':cd_customer' [getZenBundleDay] select DT_BUNDLE from T_KANRI_BUNDLE where DT_BUNDLE < to_date(':dtsYear' || lpad(':dtsMonth', 2, '0') || lpad(':dtsDay', 2, '0')) and CD_CUSTOMER = ':cd_customer'