讲解一个Informix数据库存储过程的实例

日期:2008-9-12作者:Anna来源:赛迪网

一个Informix数据库存储过程的实例:

注意:foreach后跟的select 语句不需要结束符“;”

create procedure p_95500_cxxqy_v5(dat date)

define ls_policyno char(15);

define ls_polist char(1);

define ls_classcode char(8);

define ls_apid char(18);

define ls_apname varchar(60,10);

define ls_apsex char(1);

define ls_pid char(18);

define ls_pname varchar(60,10);

define ls_recaddr varchar(60,30);

define ls_rectele char(14);

define ls_recaddr_rc varchar(60,30);

define ls_rectele_rc char(14);

define ls_ctele char(14);

define ls_ftele char(14);

define ls_mtele char(14);

define ls_appf char(1);

define ls_begdate date;

define ls_paydate date;

define ls_dbdate date;

define ls_empno char(9);

define ls_fgscode varchar(18); --负责分公司

define ls_governid varchar(18); --负责机构

define ls_ichannelcode char(2); --渠道

define ls_ipaytype char(2); --缴费方式

define ls_empname VARchar(20); --业务员姓名

define ls_emptele char (20); --业务员电话

define ls_fpayamount decimal (16,2); --缴费金额

define ls_classname VARchar(125); --险种名称

delete from p95500_cxxqy where statdate=dat;

--取分公司代码

select fgsno into ls_fgscode from fgsno_sjt;

--遍历riskcon,抽取符合条件保单

set isolation to dirty read;

select classcode from riskclass where timestr=’1’ into temp risk_time_tmp with no log;

select classcode from risklist where ( (( a4 =’01’) and (a1=’01’)) or ((a4=’04’) and (a1=’01’))) into temp risk_type_tmp with no log;

select policyno from effective where passyn=1 and opdate=dat into temp policyno_tmp;

select policyno,polist,begdate,classcode,dbdate,apid,pid,empno,appf,recaddr,rectele,paycode policyno_tmp)

and classcode in (select classcode from risk_time_tmp) and classcode in

(select classcode from risk_type_tmp) and polist in (’2’,’D’,’E’) and appf=’1’

into temp cxxqy_tmp with no log;

foreach

select policyno,polist,begdate,classcode,dbdate,apid,pid ,empno,appf,recaddr,rectele,paycode

into ls_policyno,ls_polist,ls_begdate,ls_classcode,ls_dbdate,ls_apid,ls_pid,ls_empno,ls_appf,

ls_recaddr_rc,ls_rectele_rc,ls_ipaytype

from cxxqy_tmp where policyno not in (select policyno from grplist)

if ls_policyno is null or ls_policyno = ’’ then

continue foreach;

end if

--投保人处理

execute procedure p_95500_gvid(ls_empno) into ls_governid;

--插入回访清单表

if ls_governid is null then

let

ls_governid =’’;

end if

--渠道

let ls_ichannelcode=’’;

foreach select xsqd into ls_ichannelcode from empno_xsqd where empno=ls_empno

exit foreach;

end foreach;

--业务员姓名

let ls_empname=’’;

foreach select name into ls_empname from empno where empno=ls_empno

exit foreach;

end foreach;

--业务员电话

let ls_emptele=’’;

foreach select link_tele1 into ls_emptele from empbrief where id in

(select distinct id from empno where empno =ls_empno)

exit foreach;

end foreach;

--缴费金额

let ls_fpayamount=’’;

--foreach

--险种名称

let ls_classname=’’;

foreach select classname into ls_classname from risklist where classcode=ls_classcode

exit foreach;

end foreach;

let ls_apname=’’;

let ls_apsex=’’;

let ls_ctele=’’;

let ls_ftele=’’;

foreach select name,sex,ctele,ftele into ls_apname,ls_apsex,ls_ctele,ls_ftele from custmatl where id = ls_apid

exit foreach;

end foreach;

if ls_apname is null or ls_apname=’’ then

let ls_apname=’’;

end if

--被保人处理

let ls_pname =’’;

foreach select name into ls_pname from custmatl where id = ls_pid

exit foreach;

end foreach;

let ls_mtele=’’;

let ls_rectele=’’;

let ls_recaddr=’’;

foreach select mobile,rectele,recaddr into ls_mtele,ls_rectele,ls_recaddr from custaddi where id=ls_apid

exit foreach;

end foreach;

if ls_recaddr is null or ls_recaddr =’’ then

let ls_recaddr = ls_recaddr_rc;

end if

if ls_recaddr is null then

let ls_recaddr =’’;

end if

if ls_rectele is null or ls_rectele =’’ then

let ls_rectele = ls_rectele_rc;

end if

if ls_rectele is null then

let ls_rectele =’’;

end if

insert into p95500_cxxqy(fgscode,governid,policyno,classcode,polist,appf,begdate,paydate,apid,apname,apsex,pid,pname,

recaddr,rectele,ctele,ftele,mtele,empno,statdate,ichannelcode,

ipaytype, empname, emptele, fpayamount,classname)

values(ls_fgscode,ls_governid,ls_policyno,ls_classcode,

ls_polist,ls_appf,ls_begdate,dat,ls_apid,ls_apname,ls_apsex,

ls_pid,ls_pname,ls_recaddr,ls_rectele,ls_ctele,ls_ftele,ls_mtele,ls_empno,dat,

ls_ichannelcode,ls_ipaytype, ls_empname, ls_emptele, ls_fpayamount,ls_classname);

end foreach;

--删除临时表

drop table policyno_tmp;

drop table cxxqy_tmp;

drop table risk_time_tmp;

drop table risk_type_tmp;

end procedure;

微信公众号

TechTarget微信公众号二维码

TechTarget

官方微博

TechTarget中国官方微博二维码

TechTarget中国

Informix数据库>更多

  • 趣解数据库市场竞争格局

    数据库咨询顾问Curt Monash对数据库技术的发展格局进行了趣味解读,包括如Oracle、IBM、Sybase鞥厂商之间的竞争关系。

  • 盘点数据库2014:一步之遥到云端

    年终将至,盘点开始。数据库技术重换青春,市场竞争也达到了前所未有的激烈程度。可以肯定的是,数据库未来将沿着“云”和“大数据”这两个主要方向发展。

  • IBM 2014技术峰会开幕 “融合(Mix)”成今年主题

    IBM 2014技术峰会今天在北京正式拉开帷幕。在本次大会上,IBM全面解析了应对数字经济时代发展的全新“组合式业务”(Composable Business)理念。

  • SAP针对HANA发布最新预测分析软件

    SAP日前宣布将推出最新的预测分析软件BusinessObjects Predictive Analysis,它将以两种方式发布,一种是独立的软件平台,另外一种是与SAP HANA进行集成。

相关推荐

技术手册>更多

  • 数据库管理系统选型指南

    理解不同类型的DBMS有哪些特点,以及再何时、何处(场景)使用它们是十分必要的。在这本电子书中,我们就将进行一个详细的介绍,希望能够为您的数据库选型起到帮助、指导作用。

  • SAP HANA实用手册

    在选择SAP HANA的时候,CIO需要关注哪些问题?在产品的选型、实施与上线阶段,都有哪些经验可以借鉴?在本次的TechTarget电子书中,我们将为您一一解读。它也将成为企业选择HANA时,最有实用价值的参考资料。

  • 电子书:如何选择NoSQL数据库

    很多企业关系自己是否应该从传统数据库转到NoSQL数据库,应该选择什么样的数据库?本书详列了相应的技巧和案例,供您参考。

  • 2013数据库工程师薪酬调查报告

    TechTarget数据库网站每两年就会进行一次“数据库工程师薪酬调查”,对不同行业、不同层次的数据库技术从业者的薪酬待遇情况进行一次摸底。

TechTarget

最新资源
  • 安全
  • 存储
  • CIO
  • SOA
  • 虚拟化
  • 服务器