123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_main()
- IS
- DECLARE
- individual_count int
- strsql string
- BEGIN
-
-
- shanglifeecif.init_individual_0(individual_count);
-
- individual_count:=individual_count+1;
- shanglifeecif.init_individual_1(individual_count);
-
- individual_count:=individual_count+1;
- shanglifeecif.init_individual_3(individual_count);
-
- individual_count:=individual_count+1;
- shanglifeecif.init_individual_other(individual_count);
-
-
- shanglifeecif.up_t_customers_class_1();
-
-
-
-
- shanglifeecif.up_other_customerinfo()
- END;
- /
- CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_0( individual_count OUT int)
- IS
- BEGIN
-
-
- insert into shanglifeecif.individual (
- indid,
- custid,
- scustid,
- name,
- gender,
- birthday,
- idcard,
- created_time,
- created_by
- )
- SELECT
- row_number()over(),
- 'CP'||lpad(row_number()over(),10,'0'),
- scustid ,
- max(name) as name,
- max(gender) as gender ,
- max(birthday) as birthday,
- max(idcard) as idcard,
- sysdate,
- 'admin'
- FROM (
- SELECT
- trim(customerno) AS scustid,
- trim(name) AS name,
- trim(sex) AS gender,
- trim(birthday) AS birthday,
- trim(idtype) AS idtype ,
- trim(idno) AS idcard
- FROM
- shanghailifeecif.policy_information
- WHERE customerno IS NOT NULL AND idtype=0
- UNION
- SELECT
- trim(insuredno) AS scustid,
- trim(insuredname) AS name,
- trim(insuredsex) AS gender,
- trim(insuredbirthday) AS birthday,
- trim(insuredidtype) AS idtype ,
- trim(insuredidno) AS idcard
- FROM
- shanghailifeecif.policy_information
- WHERE insuredno IS NOT NULL AND insuredidtype=0
- ) tmpTable GROUP BY scustid
-
- select count(0) into individual_count from shanglifeecif.individual
- END;
- /
- CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_1(individual_count INOUT int)
- IS
- BEGIN
-
-
- insert into shanglifeecif.individual (
- indid,
- custid,
- scustid,
- name,
- gender,
- birthday,
- passport,
- created_time,
- created_by
- )
- SELECT
- row_number()over(),
- 'CP'||lpad(row_number()over(),10,'0'),
- scustid ,
- max(name) as name,
- max(gender) as gender ,
- max(birthday) as birthday,
- max(idcard) as idcard,
- sysdate,
- 'admin'
- FROM (
- SELECT
- trim(customerno) AS scustid,
- trim(name) AS name,
- trim(sex) AS gender,
- trim(birthday) AS birthday,
- trim(idtype) AS idtype ,
- trim(idno) AS idcard
- FROM
- shanghailifeecif.policy_information
- WHERE customerno IS NOT NULL AND idtype=1
- UNION
- SELECT
- trim(insuredno) AS scustid,
- trim(insuredname) AS name,
- trim(insuredsex) AS gender,
- trim(insuredbirthday) AS birthday,
- trim(insuredidtype) AS idtype ,
- trim(insuredidno) AS idcard
- FROM
- shanghailifeecif.policy_information
- WHERE insuredno IS NOT NULL AND insuredidtype=1
- ) tmpTable GROUP BY scustid
-
- select count(0) into individual_count from shanglifeecif.individual
- END;
- /
- CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_3(individual_count INOUT int)
- IS
- BEGIN
-
-
- insert into shanglifeecif.individual(
- indid,
- custid,
- scustid,
- name,
- gender,
- birthday,
- dlicense,
- created_time,
- created_by
- )
- SELECT
- row_number()over(),
- 'CP'||lpad(row_number()over(),10,'0'),
- scustid ,
- max(name) as name,
- max(gender) as gender ,
- max(birthday) as birthday,
- max(idcard) as idcard,
- sysdate,
- 'admin'
- FROM (
- SELECT
- trim(customerno) AS scustid,
- trim(name) AS name,
- trim(sex) AS gender,
- trim(birthday) AS birthday,
- trim(idtype) AS idtype ,
- trim(idno) AS idcard
- FROM
- shanghailifeecif.policy_information
- WHERE customerno IS NOT NULL AND idtype=3
- UNION
- SELECT
- trim(insuredno) AS scustid,
- trim(insuredname) AS name,
- trim(insuredsex) AS gender,
- trim(insuredbirthday) AS birthday,
- trim(insuredidtype) AS idtype ,
- trim(insuredidno) AS idcard
- FROM
- shanghailifeecif.policy_information
- WHERE insuredno IS NOT NULL AND insuredidtype=3
- ) tmpTable GROUP BY scustid
-
- select count(0) into individual_count from shanglifeecif.individual
- END;
- /
- CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_other(individual_count INOUT int)
- IS
- BEGIN
-
-
- insert into shanglifeecif.individual(
- indid,
- custid,
- scustid,
- name,
- gender,
- birthday,
- otheridnumber,
- created_time,
- created_by
- )
- SELECT
- row_number()over(),
- 'CP'||lpad(row_number()over(),10,'0'),
- scustid ,
- max(name) as name,
- max(gender) as gender ,
- max(birthday) as birthday,
- max(idcard) as idcard,
- sysdate,
- 'admin'
- FROM (
- SELECT
- trim(customerno) AS scustid,
- trim(name) AS name,
- trim(sex) AS gender,
- trim(birthday) AS birthday,
- trim(idtype) AS idtype ,
- trim(idno) AS idcard
- FROM
- shanghailifeecif.policy_information
- WHERE customerno IS NOT NULL AND idtype not in (0,1,3)
- UNION
- SELECT
- trim(insuredno) AS scustid,
- trim(insuredname) AS name,
- trim(insuredsex) AS gender,
- trim(insuredbirthday) AS birthday,
- trim(insuredidtype) AS idtype ,
- trim(insuredidno) AS idcard
- FROM
- shanghailifeecif.policy_information
- WHERE insuredno IS NOT NULL AND insuredidtype not in (0,1,3)
- ) tmpTable GROUP BY scustid
-
- select count(0) into individual_count from shanglifeecif.individual
- END;
- /
- CREATE OR REPLACE PROCEDURE shanglifeecif.up_t_customers_class_1()
- IS
- BEGIN
- UPDATE shanglifeecif.individual a SET (
- CustClass ,
- ConValue ,
- Awarded3 ,
- Awarded2 ,
- Awarded1 ,
- SOValue ,
- EndDate,
- Height,
- Weight,
- BMI,
- PIncome,
- FIncome,
- IncomeSource,
- SIStatus,
- Ethnic,
- Nation,
- MaritalStat,
- Employer,
- Education,
- Dday,
- regtype,
- ZIPCODE,
- HPhone,
- PMPhone,
- email,
- RAL
- ) = (
- select
- b.CLASS_VALUE,
- b.CONTRIBUTION_VALUE,
- b.AWARDED3,
- b.AWARDED2,
- b.AWARDED1,
- b.TOTAL_VALUE,
- trim(b.END_DATE) as END_DATE,
- b.STATURE,
- b.AVOIRDUPOIS,
- b.BMI,
- b.YEARINCOME,
- b.FAMILYYEARSALARY,
- trim(b.INCOMESOURCE) as INCOMESOURCE,
- trim(b.SOCIALINSUFLAG) as SOCIALINSUFLAG,
- trim(b.NATIONALITY) as NATIONALITY,
- trim(b.NATIVEPLACE) as NATIVEPLACE,
- trim(b.MARRIAGE) as MARRIAGE,
- trim(b.GRPNAME) as GRPNAME,
- trim(b.DEGREE) as DEGREE,
- trim(b.DEATHDATE) as DEATHDATE,
- trim(b.DENTYPE) as DENTYPE,
- trim(b.ZIPCODE) as ZIPCODE,
- trim(b.PHONE) as PHONE,
- trim(b.MOBILE) as MOBILE,
- trim(b.EMAIL) as EMAIL,
- trim(b.POSTALADDRESS) as POSTALADDRESS
- from shanghailifeecif.t_customer_class b
- where b.CUSTOMER_ID = a.scustid
- ) WHERE 1=1 ;
- END;
- /
- CREATE OR REPLACE PROCEDURE shanglifeecif.up_other_customerinfo()
- IS
- BEGIN
-
-
- UPDATE shanglifeecif.individual i SET i.custtype = '投保人' WHERE
- i.scustid IN (SELECT p.customerno FROM shanghailifeecif.policy_information p);
-
- UPDATE shanglifeecif.individual i SET i.custtype = '被保人' WHERE
- i.scustid IN (SELECT pi.insuredno FROM shanghailifeecif.policy_information pi);
-
- UPDATE shanglifeecif.individual i SET i.custtype = '投保人、被保人' WHERE
- i.scustid IN (SELECT p.customerno FROM shanghailifeecif.policy_information p)
- AND i.scustid IN (SELECT pi.insuredno FROM shanghailifeecif.policy_information pi);
-
-
- UPDATE shanglifeecif.Individual si1 SET si1.policybelong = (
- SELECT trim(t.SALECOM) FROM (
- SELECT row_number()OVER(PARTITION BY p.customerno ORDER BY p.CUSTOMGETPOLDATE desc) rd,p.customerno,p.SALECOM FROM shanghailifeecif.policy_information p
- ) t WHERE t.rd = 1 AND si1.scustid = t.customerno
- )
-
- UPDATE shanglifeecif.Individual si1 SET si1.policybelong = (
- SELECT trim(t.SALECOM) FROM (
- SELECT row_number()OVER(PARTITION BY p.insuredno ORDER BY p.CUSTOMGETPOLDATE desc) rd,p.insuredno,p.SALECOM FROM shanghailifeecif.policy_information p
- ) t WHERE t.rd = 1 AND si1.scustid = t.insuredno
- )
-
- END;
- /
- BEGIN
- shanglifeecif.init_individual_main();
- end ;
|