create or replace procedure PROC_insertUserAmount
(
userid number,
msgtype number,
amountvalue number,
financeType number,
createUserid number,
msgId nvarchar2,
remark nvarchar2,
addtime date
)
is
v_cnt number;
v_beforevalue number;
v_aftervalue number;
v_userid number;
v_msgtype number;
begin
v_userid:=userid;
v_msgtype:=msgtype; select count(*)into v_cnt from dual
where exists (select 1 from user_amountinfo t where t.userid=v_userid and t.msgtype=v_msgtype);
if v_cnt>0 then
update user_amountinfo set amount=amount+amountvalue where user_amountinfo.userid=v_userid and user_amountinfo.msgtype=v_msgtype;
else
insert into user_amountinfo (userid,msgtype,amount)values(userid,msgtype,amountvalue);
end if; select amount-amountvalue,amount into v_beforevalue,v_aftervalue from user_amountinfo t where t.userid=v_userid and t.msgtype=v_msgtype; insert into user_amountinfodetails(userid,msgtype,beforevalue,amountvalue,aftervalue,financetype,createUserid,msgid,remark,addtime)
values(userid,msgtype,v_beforevalue,amountvalue,v_aftervalue,financetype,createUserid,msgid,remark,addtime); if(financetype<>2)then
insert into user_amountinforecharges(id,userid,msgtype,beforevalue,amountvalue,aftervalue,financetype,createUserid,msgid,remark,addtime)
values(seq_user_amountinfodetails_id.currval,userid,msgtype,v_beforevalue,amountvalue,v_aftervalue,financetype,createUserid,msgid,remark,addtime);
end if; if(financetype=1) then--类型为充值
update user_amountinfo set rechargeamount=rechargeamount+amountvalue where user_amountinfo.userid=v_userid and user_amountinfo.msgtype=v_msgtype;
end if;
commit;
exception--出现异常,回滚事务,抛出异常
when others then
rollback;
raise;
end;

最新文章

  1. JAVA6开发WebService (四)——SAAJ调用WebService
  2. Linux系统Shutdown命令定时关机详解
  3. PHP PDO获取结果集
  4. linux时钟管理
  5. 让app在ios6上具有ios7的扁平效果
  6. MongoDB的.Net驱动
  7. nGrinder 简易使用教程
  8. IdentityServer(12)- 使用 ASP.NET Core Identity
  9. 修改Java程序的进程名
  10. 记一次非常规方法对接硬件设备(Grason Stadler GSI 61)
  11. Python函数zip-map
  12. JS学习笔记Day8
  13. 安装xgboost
  14. Codeforces.1096E.The Top Scorer(组合)
  15. mitmproxy 中间人攻击的小玩笑
  16. BIT-区间修改单点查询
  17. MSSQL2012中SQL调优(SQL TUNING)时CBO支持和常用的hints
  18. xml 注意事项
  19. Android开发之将拍摄的图片传至服务器
  20. iOS App转让流程详情教程篇

热门文章

  1. IsoAlgo3d - IDF/PCF pipeline 3d viewer
  2. Http post提交和get提交
  3. C#使用一般处理程序(ashx)中session
  4. C#开发 —— 基础知识
  5. thuwc9102划水记
  6. 关于MySQL utf8mb4 字符集中字符串长度的问题
  7. PatentTips - Transparent unification of virtual machines
  8. Linux搭建aspx.net环境之:CentOs 7 安装 Mono 和 Jexus 步骤记录
  9. 怎样利用ash监控会话
  10. css笔记(二)——几种经常使用的模式