您的位置:首页 > 其它

数据移植

2008-10-26 16:35 288 查看
1.转移数据
declare JJZR_Cursor cursor for
select
a.accept_no as accept_no,
'101001' as biz_no,
TRUNCATE(round(sum(a.COM_FEE+a.COM_FEE_T),2),2) as com_capital,
TRUNCATE(round(sum(a.COM_TO_PSN_FEE+a.COM_TO_PSN_FEE_T),2),2) as com_to_psn_capital,
'105' as fund_source,
a.operator as operator,
'1' as interest_state,
'1' as insurance_kind,
'1' as fund_type,
TRUNCATE(round(sum(a.PSN_FEE+a.PSN_FEE_T),2),2) as psn_capital,
TRUNCATE(round(sum(a.COM_INTEREST+a.COM_INTEREST_T),2),2) as COM_INTEREST,
TRUNCATE(round(sum(a.COM_TO_PSN_INTEREST+a.COM_TO_PSN_INTEREST_T),2),2) as COM_TO_PSN_INTEREST,
TRUNCATE(round(sum(a.PSN_INTEREST+a.PSN_INTEREST_T),2),2) as PSN_INTEREST,
b.typ as unit_type,
b.area as si_area,
0 as availably_tag,
a.CHECK_MONTH as belong_month,
a.CHECK_MONTH*100+1 as finance_date,
a.CHECK_MONTH as finance_month,
a.CHECK_MONTH*100+1 as income_date,
2 as is_count_interest,
a.TOTAL_MONTH as month_count,
max(c.MONTH_E) as month_e,
min(c.MONTH_S) as month_s,
a.opt_time as opt_time,
a.person_base_id as person_base_id,
a.remark as remark,
a.unit_base_id as unit_base_id,
a.FINANCE_MONTH as pay_date,
'1' as BANK_LOCATE_TYPE,
'2' as BANK_STATE,
a.operator as BANK_OPERATOR,
a.opt_time as BANK_OPT_TIME,
a.settlement_id as settlement_id,
0 as jdo_version
from SETTLEMENT a, UNIT_BASE b, account_year c
where a.availably_tag=0
and b.availably_tag=0
and c.availably_tag=0
and a.unit_base_id=b.unit_base_id
and a.SETTLEMENT_id = c.SETTLEMENT_id
and c.ACC_YEAR_TYPE ='1'
and a.flag=2
and a.TYP='0'
and a.INSURED_KIND='1'
and (c.si_case_id is null or c.si_case_id not in (select si_case_id from si_case where case_type in ('0102','0103','0104','0203')))
group by a.SETTLEMENT_id,a.accept_no,a.operator,b.typ,b.area,a.CHECK_MONTH,
a.FINANCE_MONTH,a.TOTAL_MONTH,a.opt_time,a.person_base_id,a.remark,a.unit_base_id
;
load from JJZR_Cursor of cursor
INSERT INTO account_item_test(
accept_no,
biz_no,
com_capital,
com_to_psn_capital,
fund_source,
operator,
interest_state,
insurance_kind,
fund_type,
psn_capital,
COM_INTEREST,
COM_TO_PSN_INTEREST,
PSN_INTEREST,
unit_type,
si_area,
availably_tag,
belong_month,
finance_date,
finance_month,
income_date,
is_count_interest,
month_count,
month_e,
month_s,
opt_time,
person_base_id,
remark,
unit_base_id,
pay_date,
BANK_LOCATE_TYPE,
BANK_STATE,
BANK_OPERATOR,
BANK_OPT_TIME,
settlement_id,
jdo_version)
NONRECOVERABLE;
2合并数据前拷贝原数据,并修改其中的有效标志(availably_tag=-1)
insert into account_year_trans
(
ACC_YEAR_TYPE,AUDIT_FLAG,AUDIT_TIME,AUDITOR,AVAILABLY_TAG,BALANCE,
BASE,BILL_NO,BUSY_OPT_TIME,CHECK_MONTH,COM_FEE,COM_FEE_T,
COM_INTEREST,COM_INTEREST_T,COM_TO_PSN_FEE,COM_TO_PSN_FEE_T,
COM_TO_PSN_INTEREST,COM_TO_PSN_INTEREST_T,COUNT_MONTH,
COUNT_MONTH_T,INSURED_KIND,INTEREST_MONTH,JDO_VERSION,
MONTH_E,MONTH_S,OPERATOR,OPT_TIME,ORGNL_ACC_YEAR_ID,PERSON_BASE_ID,
PSN_FEE,PSN_FEE_T,PSN_INTEREST,PSN_INTEREST_T,REMARK,SETTLEMENT_ID,
SI_CASE_ID,UNIT_BASE_ID,YR
)
select
b.ACC_YEAR_TYPE,b.AUDIT_FLAG,b.AUDIT_TIME,b.AUDITOR,
-1,--有效标志为-1
b.BALANCE,b.BASE,b.BILL_NO,b.BUSY_OPT_TIME,b.CHECK_MONTH,
b.COM_FEE,b.COM_FEE_T,b.COM_INTEREST,
b.COM_INTEREST_T,b.COM_TO_PSN_FEE,b.COM_TO_PSN_FEE_T,
b.COM_TO_PSN_INTEREST,b.COM_TO_PSN_INTEREST_T,b.COUNT_MONTH,b.COUNT_MONTH_T,b.INSURED_KIND,b.INTEREST_MONTH,b.JDO_VERSION,
b.MONTH_E,b.MONTH_S,b.OPERATOR,b.OPT_TIME,b.ORGNL_ACC_YEAR_ID,
b.PERSON_BASE_ID,b.PSN_FEE,b.PSN_FEE_T,b.PSN_INTEREST,b.PSN_INTEREST_T,
b.REMARK,b.SETTLEMENT_ID,b.SI_CASE_ID,b.UNIT_BASE_ID,b.YR
from account_year_trans b
where b.ACCOUNT_YEAR_ID=?
3.复制数据前,修改主键的最大值(插入值时有主键重复提示)
select max(account_year_id) from account_year_trans -- 200027230
­
alter table account_year_trans alter account_year_id restart with 200027231
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: