修改完整版的sql存储(积分兑换脚本),改写出可执行的hive truncate table "rptdev"."rpt_wjq_jf_value_dhfz_list"; commit work; message "DATEFORMAT"("NOW"(),'YYYYMMDD HH:NN:SS') || '清空底层清单表:' || @@ROWCOUNT || ' 条' type info to client; insert into "rpt_wjq_jf_value_dhfz_list"( "cust_id","cust_name","price","gift_code","gift_name" ) select "cust_id","cust_name","price","gift_code","gift_name" --into rpt_wjq_jf_value_dhfz_list from "zwfxdev"."TB_COMM_CM_INT_USE_GIF_ALL" where convert(date,"change_date") >= @month_first_date and convert(date,"change_date") <= @stat_date; commit work; message "DATEFORMAT"("NOW"(),'YYYYMMDD HH:NN:SS') || '插入底层清单表:' || @@ROWCOUNT || ' 条' type info to client; --alter table rpt_wjq_jf_value_dhfz_list add (acc_nbr varchar(21),cust_nbr varchar(30),subst_id numeric(18));commit; --更新号码、局向 update "rpt_wjq_jf_value_dhfz_list" as "a" set "a"."acc_nbr" = "b"."acc_nbr", "a"."cust_nbr" = "b"."cust_nbr", "a"."subst_id" = "b"."subst_id" from "rptdev"."rpt_comm_cm_serv_cdma" as "b" where "a"."cust_id" = "b"."cust_id"; commit work;
时间: 2023-08-27 22:12:52 浏览: 194
以下是修改后的可执行的Hive代码:
-- 清空底层清单表
truncate table rptdev.rpt_wjq_jf_value_dhfz_list;
-- 插入底层清单表
insert into rptdev.rpt_wjq_jf_value_dhfz_list(cust_id, cust_name, price, gift_code, gift_name)
select cust_id, cust_name, price, gift_code, gift_name
from zwfxdev.TB_COMM_CM_INT_USE_GIF_ALL
where cast(change_date as date) >= '${month_first_date}' and cast(change_date as date) <= '${stat_date}';
-- 更新号码、局向
add columns if not exists (acc_nbr string, cust_nbr string, subst_id decimal(18));
update rptdev.rpt_wjq_jf_value_dhfz_list as a
set acc_nbr = b.acc_nbr, cust_nbr = b.cust_nbr, subst_id = b.subst_id
from rptdev.rpt_comm_cm_serv_cdma as b
where a.cust_id = b.cust_id;
阅读全文