プロシージャの外側で正常に動作するように見えますが、プロシージャ内では何もしないようです。プロシージャはエラーなしで実行されますが、行は挿入されません。誰でも助けてくれますか?実行するとすぐに実行する
create or replace procedure sp_retail_transaction_insert
authid current_user
as
begin
execute immediate ('
insert into sp_retail_transaction
(indiv_id, perm_id, acct_type, acct_source, tender_cd, trans_header_id, trans_datetime_full,
trans_type, tot_price_amt, promotion_code, store_name, store_type, store_cat, store_terminal_location, store_area_location, cmp_period, staff)
select
a.indiv_id,
a.perm_id,
a.acct_type,
a.acct_source,
a.tender_cd,
a.trans_header_id,
a.trans_datetime_full,
a.trans_type,
a.tot_price_amt,
a.promotion_code,
a.company_name as store_name,
a.site_type as store_type,
a.secondary_site_type as store_cat,
a.airport_terminal as store_terminal_location,
a.building_desc as store_area_location,
case when
trans_datetime_full between to_date(b.start_date, ''dd/mm/yyyy'')
and
to_date (b.end_date, ''dd/mm/yyyy'') then ''cmp_period''
when to_date(trans_datetime_full, ''dd/mm/yyyy'')<to_date(b.start_date, ''dd/mm/yyyy'') then ''pre_cmp_period''
when to_date(trans_datetime_full, ''dd/mm/yyyy'')>to_date(b.end_date, ''dd/mm/yyyy'') then ''post_cmp_period''
end as cmp_period,
case when c.staff_flag = 1 or c.staff_flag_revised = 1 or c.pseudo_staff_flag = 1 then 1 else 0 end as staff
from sp_temp b, tableau.an_retail_trans_full a
left join tableau.an_individual_tb_full c
on a.indiv_id=c.indiv_id
where a.tot_price_amt>0 and
a.indiv_id is not null and
( instr ('','' || upper(b.airport_terminal)|| '','', '','' ||upper(a.airport_terminal)|| '','') <> 0 or upper(b.airport_terminal) is null) and
( instr ('','' || upper(b.store_name) || '','', '','' || upper(a.loc_desc_long) || '','') <> 0 or upper(b.store_name) is null) and
( instr ('','' || upper(b.acct_type) || '','' , '','' || upper(a.acct_type) || '','') <> 0 or upper(b.acct_type) is null) and
( instr ('','' || upper(b.trans_type) || '','', '','' || upper(a.trans_type) || '','') <> 0 or upper(b.trans_type) is null)
and
a.trans_datetime_full between (to_date(b.start_date,''dd/mm/yyyy'')-(to_date (b.end_date,''dd/mm/yyyy'') - to_date(b.start_date,''dd/mm/yyyy'')))
and
(to_date (b.end_date,''dd/mm/yyyy'')+(to_date (b.end_date, ''dd/mm/yyyy'') - to_date(b.start_date, ''dd/mm/yyyy'')))');
end sp_retail_transaction_insert;
なぜ動的SQLを使用するのですか? – mustaccio
コミットすることを忘れないでください。 –
私はコーディングにSQL Developerを使用しています。 –