講解一個Informix數據庫存儲過程的實例

一個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;

實例講解JSP調用SQL Server的存儲過程
JSP調用SQL Server存儲過程的實例: 創建表: CREATE TABLE ( IDENTITY (1, 1) NOT NULL , (50) COLLATE Chinese_PRC_CI_AS NOT NULL , (50) COLLATE Chinese_PRC_CI_AS NOT NULL , NOT NULL C...查看完整版>>實例講解JSP調用SQL Server的存儲過程
 
Oracle中用腳本跟蹤存儲過程實例講解
一、用腳本啓動並設置跟蹤的示例 我們可以用腳本進行跟蹤存儲過程,當然要了解這些存儲過程的具體語法和參數的含義,至于這些語法和參數含義請查詢聯機幫助。下面請看一實例: /***********************************...查看完整版>>Oracle中用腳本跟蹤存儲過程實例講解
 
實例講解數據庫備份過程中的常見問題
第一個問題: 有RAID,還需要做數據庫備份嗎? 回答:需要。有了RAID,萬一部份磁盤損壞,可以修複數據庫,有的情況下數據庫甚至可以繼續使用。但是,如果哪一天,你的同事不小心刪除了一條重要的記錄,怎麽辦?RAID是...查看完整版>>實例講解數據庫備份過程中的常見問題
 
一個將數據分頁的存儲過程
CREATE PROCEDURE sp_page @tb varchar(50), --表名 @col varchar(50), --按該列來進行分頁 @col...查看完整版>>一個將數據分頁的存儲過程
 
一個將數據分頁的存儲過程
一個將數據分頁的存儲過程 一個將數據分頁的存儲過程 CREATE PROCEDURE sp_page @tb varchar(50), --表名 @col varchar(50), --按該列來進行分頁 @coltype int, --@col列的類型...查看完整版>>一個將數據分頁的存儲過程
 
一個將數據分頁的存儲過程
CREATE PROCEDURE sp_page @tb varchar(50), --表名 @col varchar(50), --按該列來進行分頁 @coltype int, 列的類型,0-數字類型,1-字符類型,2-日期時間類型 @orderby bit, ...查看完整版>>一個將數據分頁的存儲過程
 
實例講解域名被谷歌解封的過程
實例講解域名被谷歌解封的過程
  本人的域名中國花卉苗木網(www.hhhhx.com)曾經做過一段時間的垃圾圖片網站,而且使用了一定的作弊手段(網站首頁嚴重堆砌關鍵詞),先後被百度和谷歌都封過,後來百度大解封,域名被百度主動解封了。本人原來做過...查看完整版>>實例講解域名被谷歌解封的過程
 
DELPHI 調用 Oracle 存儲過程並返回數據集的例子.
   環境: Win2000 + Oracle92一、先在 Oracle 建包 CREATE OR REPLACE PACKAGE pkg_test AS TYPE myrctype IS REF CURSOR; ...查看完整版>>DELPHI 調用 Oracle 存儲過程並返回數據集的例子.
 
如何使用ADO訪問Oracle數據庫存儲過程
  ---- 一、關于ADO     ---- 在基于Client/Server結構的數據庫環境中,通過OLE DB接口可以存取數據,但它定義的是低層COM接口,不僅不易使用,而且不能被VB,VBA,VBScript等高級編程工具訪問。 ...查看完整版>>如何使用ADO訪問Oracle數據庫存儲過程
 
 
回到王朝網路移動版首頁