SQLSERVER 批量处理

来源:互联网 发布:听打测试软件 编辑:程序博客网 时间:2024/06/07 17:39
select return_periods ,is_finished ,collect_corpus ,collect_interest ,collect_total ,collect_date ,is_fykq_success, * from CHK_collect_plan_info 
where lend_info_id =6218 and return_periods=10


select b.cust_name ,b.clew_mob_tel , b.cret_code ,c.is_finished, prop_type ,a.is_loan ,c.is_finished ,f.contract_no,
f.loan_money,c.sett_money ,a.lend_info_id ,b.cust_id ,e.org_name , * from CHK_lend_info a inner join CST_cust b on a.cust_id=b.cust_id  
inner join APP_lend_paper
c on a.lend_info_id=c.lend_info_id inner join ORG_org_info e on a.org_id=e.org_id inner join APP_lend_contract f on a.lend_info_id=f.lend_info_id
where b.cust_name like '%叶传兵%'




select return_periods ,is_finished ,collect_corpus ,collect_total ,collect_date ,is_fykq_success, * from CHK_collect_plan_info 
where lend_info_id =5833 




select d.cust_name ,c.is_dock ,c.invest_affirm_id , * from  FRM_match_detail_record a inner join FRM_match_total_record b on a.total_match_id=b.total_match_id
inner join FRM_captial_invest_affirm c on b.invest_affirm_id=c.invest_affirm_id 
inner join CST_cust d  on c.cust_id=d.cust_id  where  ISNULL(del_flg ,0)=0 and lend_info_id=6250


select SUM(match_money) from FRM_match_detail_record where lend_info_id=6250 and  ISNULL(del_flg ,0)=0


-----------------*********处理任红军6093 收回一期标准版本*************------




-------------脚本开始------------------------
declare @keyId int
declare @lendinfoid int 
declare @collectcorups decimal(18,4)
declare @collectinterest decimal(18,4)
declare @payid int 
declare @returnperiods int


 begin
 set @returnperiods=15;
set @lendinfoid=6218


 update CHK_collect_plan_info set is_finished=1,receive_corpus=collect_corpus ,receive_interest=collect_interest  where 
lend_info_id=@lendinfoid and return_periods=@returnperiods
-------------------------添加收回表-------------------------------------


select @keyId = Max_Id+1 from Table_Key where Table_Name='CLN_capital_interest'
select @collectcorups =collect_corpus ,@collectinterest=collect_interest from CHK_collect_plan_info where lend_info_id=@lendinfoid and return_periods=@returnperiods
INSERT INTO [CLN_capital_interest]
           ([pay_id] 
           ,[lend_info_id]
           ,[receive_volume] 
           ,[receive_capital] 
           ,[receive_interest]
)VALUES
            (@keyId,@lendinfoid,@returnperiods,@collectcorups,@collectinterest) 
update Table_Key set max_id=@keyId where Table_Name='CLN_capital_interest'


update CLN_capital_interest set collect_capital=receive_capital ,collect_interest =receive_interest ,receive_total_money=receive_capital+receive_interest 
  where lend_info_id=@lendinfoid and receive_volume =@returnperiods
--------------添加收回表明细表-------------------
select @payid=pay_id  from CLN_capital_interest   where lend_info_id=@lendinfoid and receive_volume =@returnperiods


select @keyId = Max_Id+1 from Table_Key where Table_Name='CLN_repay_detail'
INSERT INTO [CLN_repay_detail]
           ([paper_fee_id]
           ,[lend_info_id]   
           ,[cost_id]
           ,[cost_name]  
           ,[collect_money] 
           ,[pay_id] 
           ,[receive_volume]
           ,[is_recieved]
           
)VALUES
            (@keyId,@lendinfoid,'-500','本金',@collectcorups,@payid,@returnperiods ,1) 
            
update Table_Key set max_id=@keyId where Table_Name='CLN_repay_detail'


---------利息------
select @keyId = Max_Id+1 from Table_Key where Table_Name='CLN_repay_detail'
INSERT INTO [CLN_repay_detail]
           ([paper_fee_id]
           ,[lend_info_id]   
           ,[cost_id]
           ,[cost_name]  
           ,[collect_money] 
           ,[pay_id] 
           ,[receive_volume] 
          ,[is_recieved]
          
          
)VALUES
            (@keyId,@lendinfoid,'-400','利息',@collectinterest,@payid,@returnperiods ,1) 
update Table_Key set max_id=@keyId where Table_Name='CLN_repay_detail'


update CLN_repay_detail set receive_money=collect_money ,statistics_cost_way=2,before_or_after=2,add_date=GETDATE() where lend_info_id=@lendinfoid and receive_volume=@returnperiods
end


-------------------解除债券
--张文栋多出 1913.5900
update FRM_match_detail_record set match_money-= 1913.5900 where match_id=44540


update FRM_match_total_record set match_loan_total_money-=1913.5900 where total_match_id=14409
------------------------------*************处理脚本结束*********************-------------------------------------------



















--**************************************************************************************************************
0 0
原创粉丝点击