declare
oper_id number(30) := 10100798110100153219;
product_offer_ID number(12) :=9726133598;
partition_id number(4) := 1013;
product_record ls65_sid.product_offer_instance_t%rowtype;
offer_record ls65_sid.offer_detail_instance_t%rowtype;
crm_prod_record bss_ods.inf_bill_prod_offer_inst%rowtype;
flag number := 2; --0为补商品实例,1为补明细,2为补商品实例和明细。
begin
select * into crm_prod_record
from bss_ods.inf_bill_prod_offer_inst a
where a.oper_seq_id = oper_id and a.product_offer_instance_id = product_offer_ID;
case flag
when 0 then --补商品实例
select a.product_offer_instance_id, 0, a.cust_id, 0, a.eff_date, '10A', '00A', a.state_date, a.state_date,
a.exp_date, substr(to_char(to_date(a.eff_date, 'yyyymmdd')), 1, 6),substr(to_char(to_date(a.exp_date, 'yyyymmdd')), 1, 6),
'55555', sysdate, partition_id, partition_id, 0
into product_record.product_offer_instance_id, product_record.brand_id, product_record.cust_id,
product_record.agreement_id, product_record.eff_date, product_record.instance_type,
product_record.state, product_record.state_date, product_record.apply_date, product_record.exp_date,
product_record.eff_acct_month, product_record.exp_acct_month, product_record.oper_serial_nbr,
product_record.modify_time, product_record.region_id, product_record.partition_id_region, product_record.data_type
from bss_ods.inf_bill_prod_offer_inst a
where a.oper_seq_id = oper_id and a.product_offer_instance_id = product_offer_ID;
select max(a.product_offer_instance_seq_id) into product_record.product_offer_instance_seq_id
from ls65_sid.product_offer_instance_t a
where a.product_offer_instance_id = product_offer_ID;
if product_record.product_offer_instance_seq_id is null then
product_record.product_offer_instance_seq_id := 1;
else
product_record.product_offer_instance_seq_id := product_record.product_offer_instance_seq_id + 1;
end if;
select distinct a.jf_offer_id into product_record.product_offer_id from ls65_para.product_offer_relation_t a
where a.jt_offer_code = crm_prod_record.product_offer_id and a.crm2_offer_kind = crm_prod_record.offer_kind;
insert into ls65_sid.product_offer_instance_t values product_record;
when 1 then --补商品明细
select a.instance_relation_id, a.product_offer_instance_id, 0, a.instance_type, '00A', a.eff_date, a.exp_date,
a.detail_id, a.instance_id, 0, 0, 0, substr(to_char(to_date(a.eff_date, 'yyyymmdd')), 1, 6),
substr(to_char(to_date(a.exp_date, 'yyyymmdd')), 1, 6), '55555', sysdate, partition_id, partition_id, 0
into offer_record.instance_relation_id, offer_record.product_offer_instance_id, offer_record.agreement_id,
offer_record.instance_type, offer_record.state, offer_record.eff_date, offer_record.exp_date,
offer_record.offer_detail_id, offer_record.serv_id, offer_record.serv_product_id,
offer_record.product_bundle_instance_id, offer_record.product_bundle_id, offer_record.eff_acct_month,
offer_record.exp_acct_month, offer_record.oper_serial_nbr, offer_record.modify_time,
offer_record.region_id, offer_record.partition_id_region, offer_record.data_type
from bss_ods.inf_bill_offer_inst_detail a
where a.oper_seq_id = oper_id and a.product_offer_instance_id = product_offer_ID;
select distinct a.jf_offer_id into offer_record.product_offer_id
from ls65_para.product_offer_relation_t a
where a.jt_offer_code = crm_prod_record.product_offer_id and a.crm2_offer_kind = crm_prod_record.offer_kind;
insert into ls65_sid.offer_detail_instance_t values offer_record;
when 2 then
select a.product_offer_instance_id, 0, a.cust_id, 0, a.eff_date, '10A', '00A', a.state_date, a.state_date,
a.exp_date, substr(to_char(to_date(a.eff_date, 'yyyymmdd')), 1, 6),substr(to_char(to_date(a.exp_date, 'yyyymmdd')), 1, 6),
'55555', sysdate, partition_id, partition_id, 0
into product_record.product_offer_instance_id, product_record.brand_id, product_record.cust_id,
product_record.agreement_id, product_record.eff_date, product_record.instance_type,
product_record.state, product_record.state_date, product_record.apply_date, product_record.exp_date,
product_record.eff_acct_month, product_record.exp_acct_month, product_record.oper_serial_nbr,
product_record.modify_time, product_record.region_id, product_record.partition_id_region, product_record.data_type
from bss_ods.inf_bill_prod_offer_inst a
where a.oper_seq_id = oper_id and a.product_offer_instance_id = product_offer_ID;
select max(a.product_offer_instance_seq_id) into product_record.product_offer_instance_seq_id
from ls65_sid.product_offer_instance_t a
where a.product_offer_instance_id = product_offer_ID;
if product_record.product_offer_instance_seq_id is null then
product_record.product_offer_instance_seq_id := 1;
else
product_record.product_offer_instance_seq_id := product_record.product_offer_instance_seq_id + 1;
end if;
select distinct a.jf_offer_id into product_record.product_offer_id from ls65_para.product_offer_relation_t a
where a.jt_offer_code = crm_prod_record.product_offer_id and a.crm2_offer_kind = crm_prod_record.offer_kind;
insert into ls65_sid.product_offer_instance_t values product_record;
select a.instance_relation_id, a.product_offer_instance_id, 0, a.instance_type, '00A', a.eff_date, a.exp_date,
a.detail_id, a.instance_id, 0, 0, 0, substr(to_char(to_date(a.eff_date, 'yyyymmdd')), 1, 6),
substr(to_char(to_date(a.exp_date, 'yyyymmdd')), 1, 6), '55555', sysdate, partition_id, partition_id, 0
into offer_record.instance_relation_id, offer_record.product_offer_instance_id, offer_record.agreement_id,
offer_record.instance_type, offer_record.state, offer_record.eff_date, offer_record.exp_date,
offer_record.offer_detail_id, offer_record.serv_id, offer_record.serv_product_id,
offer_record.product_bundle_instance_id, offer_record.product_bundle_id, offer_record.eff_acct_month,
offer_record.exp_acct_month, offer_record.oper_serial_nbr, offer_record.modify_time,
offer_record.region_id, offer_record.partition_id_region, offer_record.data_type
from bss_ods.inf_bill_offer_inst_detail a
where a.oper_seq_id = oper_id and a.product_offer_instance_id = product_offer_ID;
select distinct a.jf_offer_id into offer_record.product_offer_id
from ls65_para.product_offer_relation_t a
where a.jt_offer_code = crm_prod_record.product_offer_id and a.crm2_offer_kind = crm_prod_record.offer_kind;
insert into ls65_sid.offer_detail_instance_t values offer_record;
end case;
end;
块语句跑到
select * into crm_prod_record
from bss_ods.inf_bill_prod_offer_inst a
where a.oper_seq_id = oper_id and a.product_offer_instance_id = product_offer_ID;
就报错:no data founded。
有请大虾讲解一下相关的知识。呵呵。
oper_id number(30) := 10100798110100153219;
product_offer_ID number(12) :=9726133598;
partition_id number(4) := 1013;
product_record ls65_sid.product_offer_instance_t%rowtype;
offer_record ls65_sid.offer_detail_instance_t%rowtype;
crm_prod_record bss_ods.inf_bill_prod_offer_inst%rowtype;
flag number := 2; --0为补商品实例,1为补明细,2为补商品实例和明细。
begin
select * into crm_prod_record
from bss_ods.inf_bill_prod_offer_inst a
where a.oper_seq_id = oper_id and a.product_offer_instance_id = product_offer_ID;
case flag
when 0 then --补商品实例
select a.product_offer_instance_id, 0, a.cust_id, 0, a.eff_date, '10A', '00A', a.state_date, a.state_date,
a.exp_date, substr(to_char(to_date(a.eff_date, 'yyyymmdd')), 1, 6),substr(to_char(to_date(a.exp_date, 'yyyymmdd')), 1, 6),
'55555', sysdate, partition_id, partition_id, 0
into product_record.product_offer_instance_id, product_record.brand_id, product_record.cust_id,
product_record.agreement_id, product_record.eff_date, product_record.instance_type,
product_record.state, product_record.state_date, product_record.apply_date, product_record.exp_date,
product_record.eff_acct_month, product_record.exp_acct_month, product_record.oper_serial_nbr,
product_record.modify_time, product_record.region_id, product_record.partition_id_region, product_record.data_type
from bss_ods.inf_bill_prod_offer_inst a
where a.oper_seq_id = oper_id and a.product_offer_instance_id = product_offer_ID;
select max(a.product_offer_instance_seq_id) into product_record.product_offer_instance_seq_id
from ls65_sid.product_offer_instance_t a
where a.product_offer_instance_id = product_offer_ID;
if product_record.product_offer_instance_seq_id is null then
product_record.product_offer_instance_seq_id := 1;
else
product_record.product_offer_instance_seq_id := product_record.product_offer_instance_seq_id + 1;
end if;
select distinct a.jf_offer_id into product_record.product_offer_id from ls65_para.product_offer_relation_t a
where a.jt_offer_code = crm_prod_record.product_offer_id and a.crm2_offer_kind = crm_prod_record.offer_kind;
insert into ls65_sid.product_offer_instance_t values product_record;
when 1 then --补商品明细
select a.instance_relation_id, a.product_offer_instance_id, 0, a.instance_type, '00A', a.eff_date, a.exp_date,
a.detail_id, a.instance_id, 0, 0, 0, substr(to_char(to_date(a.eff_date, 'yyyymmdd')), 1, 6),
substr(to_char(to_date(a.exp_date, 'yyyymmdd')), 1, 6), '55555', sysdate, partition_id, partition_id, 0
into offer_record.instance_relation_id, offer_record.product_offer_instance_id, offer_record.agreement_id,
offer_record.instance_type, offer_record.state, offer_record.eff_date, offer_record.exp_date,
offer_record.offer_detail_id, offer_record.serv_id, offer_record.serv_product_id,
offer_record.product_bundle_instance_id, offer_record.product_bundle_id, offer_record.eff_acct_month,
offer_record.exp_acct_month, offer_record.oper_serial_nbr, offer_record.modify_time,
offer_record.region_id, offer_record.partition_id_region, offer_record.data_type
from bss_ods.inf_bill_offer_inst_detail a
where a.oper_seq_id = oper_id and a.product_offer_instance_id = product_offer_ID;
select distinct a.jf_offer_id into offer_record.product_offer_id
from ls65_para.product_offer_relation_t a
where a.jt_offer_code = crm_prod_record.product_offer_id and a.crm2_offer_kind = crm_prod_record.offer_kind;
insert into ls65_sid.offer_detail_instance_t values offer_record;
when 2 then
select a.product_offer_instance_id, 0, a.cust_id, 0, a.eff_date, '10A', '00A', a.state_date, a.state_date,
a.exp_date, substr(to_char(to_date(a.eff_date, 'yyyymmdd')), 1, 6),substr(to_char(to_date(a.exp_date, 'yyyymmdd')), 1, 6),
'55555', sysdate, partition_id, partition_id, 0
into product_record.product_offer_instance_id, product_record.brand_id, product_record.cust_id,
product_record.agreement_id, product_record.eff_date, product_record.instance_type,
product_record.state, product_record.state_date, product_record.apply_date, product_record.exp_date,
product_record.eff_acct_month, product_record.exp_acct_month, product_record.oper_serial_nbr,
product_record.modify_time, product_record.region_id, product_record.partition_id_region, product_record.data_type
from bss_ods.inf_bill_prod_offer_inst a
where a.oper_seq_id = oper_id and a.product_offer_instance_id = product_offer_ID;
select max(a.product_offer_instance_seq_id) into product_record.product_offer_instance_seq_id
from ls65_sid.product_offer_instance_t a
where a.product_offer_instance_id = product_offer_ID;
if product_record.product_offer_instance_seq_id is null then
product_record.product_offer_instance_seq_id := 1;
else
product_record.product_offer_instance_seq_id := product_record.product_offer_instance_seq_id + 1;
end if;
select distinct a.jf_offer_id into product_record.product_offer_id from ls65_para.product_offer_relation_t a
where a.jt_offer_code = crm_prod_record.product_offer_id and a.crm2_offer_kind = crm_prod_record.offer_kind;
insert into ls65_sid.product_offer_instance_t values product_record;
select a.instance_relation_id, a.product_offer_instance_id, 0, a.instance_type, '00A', a.eff_date, a.exp_date,
a.detail_id, a.instance_id, 0, 0, 0, substr(to_char(to_date(a.eff_date, 'yyyymmdd')), 1, 6),
substr(to_char(to_date(a.exp_date, 'yyyymmdd')), 1, 6), '55555', sysdate, partition_id, partition_id, 0
into offer_record.instance_relation_id, offer_record.product_offer_instance_id, offer_record.agreement_id,
offer_record.instance_type, offer_record.state, offer_record.eff_date, offer_record.exp_date,
offer_record.offer_detail_id, offer_record.serv_id, offer_record.serv_product_id,
offer_record.product_bundle_instance_id, offer_record.product_bundle_id, offer_record.eff_acct_month,
offer_record.exp_acct_month, offer_record.oper_serial_nbr, offer_record.modify_time,
offer_record.region_id, offer_record.partition_id_region, offer_record.data_type
from bss_ods.inf_bill_offer_inst_detail a
where a.oper_seq_id = oper_id and a.product_offer_instance_id = product_offer_ID;
select distinct a.jf_offer_id into offer_record.product_offer_id
from ls65_para.product_offer_relation_t a
where a.jt_offer_code = crm_prod_record.product_offer_id and a.crm2_offer_kind = crm_prod_record.offer_kind;
insert into ls65_sid.offer_detail_instance_t values offer_record;
end case;
end;
块语句跑到
select * into crm_prod_record
from bss_ods.inf_bill_prod_offer_inst a
where a.oper_seq_id = oper_id and a.product_offer_instance_id = product_offer_ID;
就报错:no data founded。
有请大虾讲解一下相关的知识。呵呵。
http://topic.csdn.net/u/20081112/20/1445babb-8628-44b6-bd0b-b8fdb3fdc0aa.html