客户信息.sql 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_main() -- 初始化 数据全部插入
  2. IS
  3. DECLARE
  4. individual_count int
  5. strsql string
  6. BEGIN
  7. shanglifeecif.customertotaltemp();
  8. DELETE FROM shanglifeecif.individual;
  9. --初始化客户信息
  10. shanglifeecif.init_all_individual();
  11. --更新用户等级信息
  12. shanglifeecif.up_t_customers_class_1();
  13. --更新其它信息
  14. shanglifeecif.up_other_customerinfo();
  15. --更新被保人其它信息
  16. shanglifeecif.update_insuredinfo();
  17. END;
  18. /
  19. CREATE OR REPLACE PROCEDURE shanglifeecif.customertotaltemp() IS
  20. DECLARE
  21. BEGIN
  22. DELETE FROM shanglifeecif.customertotaltemp;
  23. insert into shanglifeecif.customertotaltemp(
  24. scustid,
  25. name,
  26. gender,
  27. birthday,
  28. idcard,
  29. idtype
  30. )
  31. SELECT
  32. scustid ,
  33. max(name) as name,
  34. max(gender) as gender ,
  35. to_char(max(birthday),"yyyy-MM-dd") birthday,
  36. max(idcard) as idcard,
  37. max(idtype) AS idtype
  38. FROM (
  39. SELECT
  40. trim(customerno) AS scustid,--投保人
  41. trim(name) AS name,
  42. trim(sex) AS gender,
  43. trim(birthday) AS birthday,
  44. trim(idtype) AS idtype ,
  45. trim(idno) AS idcard
  46. FROM
  47. policy_information
  48. WHERE customerno IS NOT NULL
  49. UNION
  50. SELECT
  51. trim(insuredno) AS scustid,--被保人
  52. trim(insuredname) AS name,
  53. trim(insuredsex) AS gender,
  54. trim(insuredbirthday) AS birthday,
  55. trim(insuredidtype) AS idtype ,
  56. trim(insuredidno) AS idcard
  57. FROM
  58. policy_information
  59. WHERE insuredno IS NOT NULL
  60. ) tmpTable GROUP BY scustid;
  61. UPDATE shanglifeecif.customertotaltemp sct SET sct.mobile = (SELECT trim(t.MOBILE) FROM t_customer_class t WHERE sct.scustid=t.customer_id);
  62. EXCEPTION
  63. WHEN HIVE_EXCEPTION THEN
  64. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  65. WHEN Others THEN
  66. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  67. END ;
  68. /
  69. CREATE OR REPLACE PROCEDURE shanglifeecif.init_all_individual() -- 初始化所有客户信息
  70. IS
  71. BEGIN
  72. --查询出此次处理的数据并出表中
  73. insert into shanglifeecif.individual (
  74. indid,
  75. custid,
  76. scustid,
  77. name,
  78. gender,
  79. birthday,
  80. idcard,
  81. Passport,
  82. Dlicense,
  83. OtherIdNumber,
  84. created_time,
  85. created_by
  86. ) SELECT
  87. row_number()OVER(ORDER BY sc.scustid),
  88. 'CP'||lpad(row_number()over(ORDER BY sc.scustid),10,'0'),
  89. sc.scustid,
  90. sc.name,
  91. sc.gender,
  92. sc.birthday,
  93. CASE sc.idtype WHEN '0' THEN sc.idcard END AS idcard,
  94. CASE sc.idtype WHEN '1' THEN sc.idcard END AS passport,
  95. CASE sc.idtype WHEN '3' THEN sc.idcard END AS dlicense,
  96. CASE WHEN sc.idtype <> '0' AND sc.idtype <> '1' AND sc.idtype <> '3' THEN sc.idcard END AS otherIdnumber,
  97. sysdate,
  98. 'admin'
  99. FROM shanglifeecif.customertotaltemp sc ORDER BY sc.scustid;
  100. EXCEPTION
  101. WHEN HIVE_EXCEPTION THEN
  102. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  103. WHEN Others THEN
  104. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  105. END;
  106. /*
  107. CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_0( individual_count OUT int) -- 初始化 身份证
  108. IS
  109. BEGIN
  110. --查询出此次处理的数据并出表中
  111. insert into shanglifeecif.individual (
  112. indid,
  113. custid,
  114. scustid,
  115. name,
  116. gender,
  117. birthday,
  118. idcard,
  119. created_time,
  120. created_by
  121. )
  122. SELECT
  123. row_number()over(),
  124. 'CP'||lpad(row_number()over(),10,'0'),
  125. scustid ,
  126. max(name) as name,
  127. max(gender) as gender ,
  128. max(birthday) as birthday,
  129. max(idcard) as idcard,
  130. sysdate,
  131. 'admin'
  132. FROM (
  133. SELECT
  134. trim(customerno) AS scustid,--投保人
  135. trim(name) AS name,
  136. trim(sex) AS gender,
  137. trim(birthday) AS birthday,
  138. trim(idtype) AS idtype ,
  139. trim(idno) AS idcard
  140. FROM
  141. policy_information
  142. WHERE customerno IS NOT NULL AND idtype=0
  143. UNION
  144. SELECT
  145. trim(insuredno) AS scustid,--被保人
  146. trim(insuredname) AS name,
  147. trim(insuredsex) AS gender,
  148. trim(insuredbirthday) AS birthday,
  149. trim(insuredidtype) AS idtype ,
  150. trim(insuredidno) AS idcard
  151. FROM
  152. policy_information
  153. WHERE insuredno IS NOT NULL AND insuredidtype=0
  154. ) tmpTable GROUP BY scustid
  155. --已经存在的数据行数
  156. select count(0) into individual_count from shanglifeecif.individual;
  157. EXCEPTION
  158. WHEN HIVE_EXCEPTION THEN
  159. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  160. WHEN Others THEN
  161. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  162. END;
  163. /
  164. CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_1(individual_count INOUT int) -- 初始化 护照
  165. IS
  166. BEGIN
  167. --查询出此次处理的数据并出表中
  168. insert into shanglifeecif.individual (
  169. indid,
  170. custid,
  171. scustid,
  172. name,
  173. gender,
  174. birthday,
  175. passport,
  176. created_time,
  177. created_by
  178. )
  179. SELECT
  180. row_number()over(),
  181. 'CP'||lpad(row_number()over(),10,'0'),
  182. scustid ,
  183. max(name) as name,
  184. max(gender) as gender ,
  185. max(birthday) as birthday,
  186. max(idcard) as idcard,
  187. sysdate,
  188. 'admin'
  189. FROM (
  190. SELECT
  191. trim(customerno) AS scustid,--投保人
  192. trim(name) AS name,
  193. trim(sex) AS gender,
  194. trim(birthday) AS birthday,
  195. trim(idtype) AS idtype ,
  196. trim(idno) AS idcard
  197. FROM
  198. policy_information
  199. WHERE customerno IS NOT NULL AND idtype=1
  200. UNION
  201. SELECT
  202. trim(insuredno) AS scustid,--被保人
  203. trim(insuredname) AS name,
  204. trim(insuredsex) AS gender,
  205. trim(insuredbirthday) AS birthday,
  206. trim(insuredidtype) AS idtype ,
  207. trim(insuredidno) AS idcard
  208. FROM
  209. policy_information
  210. WHERE insuredno IS NOT NULL AND insuredidtype=1
  211. ) tmpTable GROUP BY scustid
  212. --已经存在的数据行数
  213. select count(0) into individual_count from shanglifeecif.individual;
  214. EXCEPTION
  215. WHEN HIVE_EXCEPTION THEN
  216. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  217. WHEN Others THEN
  218. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  219. END;
  220. /
  221. CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_3(individual_count INOUT int) -- 初始化 驾照
  222. IS
  223. BEGIN
  224. --查询出此次处理的数据并出表中
  225. insert into shanglifeecif.individual(
  226. indid,
  227. custid,
  228. scustid,
  229. name,
  230. gender,
  231. birthday,
  232. dlicense,
  233. created_time,
  234. created_by
  235. )
  236. SELECT
  237. row_number()over(),
  238. 'CP'||lpad(row_number()over(),10,'0'),
  239. scustid ,
  240. max(name) as name,
  241. max(gender) as gender ,
  242. max(birthday) as birthday,
  243. max(idcard) as idcard,
  244. sysdate,
  245. 'admin'
  246. FROM (
  247. SELECT
  248. trim(customerno) AS scustid,--投保人
  249. trim(name) AS name,
  250. trim(sex) AS gender,
  251. trim(birthday) AS birthday,
  252. trim(idtype) AS idtype ,
  253. trim(idno) AS idcard
  254. FROM
  255. policy_information
  256. WHERE customerno IS NOT NULL AND idtype=3
  257. UNION
  258. SELECT
  259. trim(insuredno) AS scustid,--被保人
  260. trim(insuredname) AS name,
  261. trim(insuredsex) AS gender,
  262. trim(insuredbirthday) AS birthday,
  263. trim(insuredidtype) AS idtype ,
  264. trim(insuredidno) AS idcard
  265. FROM
  266. policy_information
  267. WHERE insuredno IS NOT NULL AND insuredidtype=3
  268. ) tmpTable GROUP BY scustid
  269. --已经存在的数据行数
  270. select count(0) into individual_count from shanglifeecif.individual;
  271. EXCEPTION
  272. WHEN HIVE_EXCEPTION THEN
  273. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  274. WHEN Others THEN
  275. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  276. END;
  277. /
  278. CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_other(individual_count INOUT int) -- 初始化除了以上三种证件信息
  279. IS
  280. BEGIN
  281. --查询出此次处理的数据并出表中
  282. insert into shanglifeecif.individual(
  283. indid,
  284. custid,
  285. scustid,
  286. name,
  287. gender,
  288. birthday,
  289. otheridnumber,
  290. created_time,
  291. created_by
  292. )
  293. SELECT
  294. row_number()over(),
  295. 'CP'||lpad(row_number()over(),10,'0'),
  296. scustid ,
  297. max(name) as name,
  298. max(gender) as gender ,
  299. max(birthday) as birthday,
  300. max(idcard) as idcard,
  301. sysdate,
  302. 'admin'
  303. FROM (
  304. SELECT
  305. trim(customerno) AS scustid,--投保人
  306. trim(name) AS name,
  307. trim(sex) AS gender,
  308. trim(birthday) AS birthday,
  309. trim(idtype) AS idtype ,
  310. trim(idno) AS idcard
  311. FROM
  312. policy_information
  313. WHERE customerno IS NOT NULL AND idtype not in (0,1,3)
  314. UNION
  315. SELECT
  316. trim(insuredno) AS scustid,--被保人
  317. trim(insuredname) AS name,
  318. trim(insuredsex) AS gender,
  319. trim(insuredbirthday) AS birthday,
  320. trim(insuredidtype) AS idtype ,
  321. trim(insuredidno) AS idcard
  322. FROM
  323. policy_information
  324. WHERE insuredno IS NOT NULL AND insuredidtype not in (0,1,3)
  325. ) tmpTable GROUP BY scustid
  326. --已经存在的数据行数
  327. select count(0) into individual_count from shanglifeecif.individual;
  328. EXCEPTION
  329. WHEN HIVE_EXCEPTION THEN
  330. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  331. WHEN Others THEN
  332. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  333. END;
  334. */
  335. CREATE OR REPLACE PROCEDURE shanglifeecif.up_t_customers_class_1() -- 创建存储过程
  336. IS
  337. BEGIN
  338. UPDATE shanglifeecif.individual a SET (
  339. CustClass ,-- 客户等级
  340. ConValue ,-- 贡献度分
  341. Awarded3 ,-- 家庭加分2
  342. Awarded2 ,-- 续期加分
  343. Awarded1 ,-- 保单加分
  344. SOValue ,-- 总分值
  345. EndDate, -- 客户等级失效日期
  346. Height, --身高
  347. Weight, --体重
  348. BMI,
  349. PIncome, --个人年收入
  350. FIncome, --家庭年收入
  351. IncomeSource, --收入来源
  352. SIStatus, --社保情况
  353. --Ethnic, --民族情况
  354. Nation, --国籍
  355. MaritalStat, --婚姻
  356. Employer,--工作单位
  357. --Education,--学历
  358. Dday, --死亡日期
  359. regtype, --户籍类型
  360. ZIPCODE,--邮编
  361. HPhone,--电话
  362. PMPhone,--手机
  363. email, -- 邮箱
  364. RAL, --联系地址
  365. sobirth --省份
  366. ) = (
  367. select
  368. b.CLASS_VALUE,--客户等级
  369. b.CONTRIBUTION_VALUE,--贡献度分
  370. b.AWARDED3, --家庭加分
  371. b.AWARDED2, --续期加分
  372. b.AWARDED1, --保单加分
  373. b.TOTAL_VALUE, --总分值
  374. trim(b.END_DATE) as END_DATE, --失效日期
  375. b.STATURE, --身高
  376. b.AVOIRDUPOIS,--体重
  377. b.BMI, --根据身高体重计算
  378. b.YEARINCOME, --个人年收入
  379. b.FAMILYYEARSALARY, --家庭年收入
  380. trim(b.INCOMESOURCE) as INCOMESOURCE, --收入来源
  381. trim(b.SOCIALINSUFLAG) as SOCIALINSUFLAG, --社保情况
  382. --trim(b.NATIONALITY) as NATIONALITY, --民族情况
  383. trim(b.NATIVEPLACE) as NATIVEPLACE, --国籍
  384. trim(b.MARRIAGE) as MARRIAGE,--婚姻
  385. trim(b.GRPNAME) as GRPNAME,--工作单位名称
  386. --trim(b.DEGREE) as DEGREE,--学历
  387. trim(b.DEATHDATE) as DEATHDATE,--死亡日期
  388. trim(b.DENTYPE) as DENTYPE,--户籍类型
  389. trim(b.ZIPCODE) as ZIPCODE,--邮编
  390. trim(b.PHONE) as PHONE,--电话
  391. trim(b.MOBILE) as MOBILE,--手机
  392. trim(b.EMAIL) as EMAIL,--邮箱
  393. regexp_replace(trim(b.POSTALADDRESS),'[0-9]','*') as POSTALADDRESS, --联系地址
  394. regexp_extract(b.POSTALADDRESS,'(.*?)省|(.*?)市',0) -- 省份
  395. from dsj.t_customer_class b
  396. where b.CUSTOMER_ID = a.scustid
  397. ) WHERE 1=1 ;
  398. EXCEPTION
  399. WHEN HIVE_EXCEPTION THEN
  400. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  401. WHEN Others THEN
  402. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  403. END;
  404. /
  405. CREATE OR REPLACE PROCEDURE shanglifeecif.up_other_customerinfo() -- 创建存储过程
  406. IS
  407. BEGIN
  408. --更新客户类型投保人
  409. UPDATE shanglifeecif.individual i SET i.custtype = '投保人' WHERE
  410. i.scustid IN (SELECT p.customerno FROM policy_information p);
  411. --更新客户类型被保人
  412. UPDATE shanglifeecif.individual i SET i.custtype = '被保人' WHERE
  413. i.scustid IN (SELECT pi.insuredno FROM policy_information pi);
  414. --更新客户类型投保人、被保人
  415. UPDATE shanglifeecif.individual i SET i.custtype = '投保人、被保人' WHERE
  416. i.scustid IN (SELECT p.customerno FROM policy_information p)
  417. AND i.scustid IN (SELECT pi.insuredno FROM policy_information pi);
  418. --更新业绩归属
  419. UPDATE shanglifeecif.Individual si1 SET si1.policybelong = (
  420. SELECT trim(t.SALECOM) FROM (
  421. SELECT row_number()OVER(PARTITION BY p.customerno ORDER BY p.polapplydate asc) rd,p.customerno,p.SALECOM FROM policy_information p
  422. ) t WHERE t.rd = 1 AND si1.scustid = t.customerno
  423. );
  424. UPDATE shanglifeecif.Individual si1 SET si1.policybelong = (
  425. SELECT trim(t.SALECOM) FROM (
  426. SELECT row_number()OVER(PARTITION BY p.insuredno ORDER BY p.polapplydate asc) rd,p.insuredno,p.SALECOM FROM policy_information p
  427. ) t WHERE t.rd = 1 AND si1.scustid = t.insuredno
  428. );
  429. --更新职业,民族等信息
  430. UPDATE shanglifeecif.Individual si1 SET (si1.Occupation,si1.Ethnic) = (
  431. SELECT trim(t.occupationname),trim(t.NATIONALITYNAME) FROM (
  432. SELECT row_number()OVER(PARTITION BY p.customerno ORDER BY p.polapplydate desc) rd,p.customerno,p.occupationname,p.NATIONALITYNAME FROM policy_information p
  433. ) t WHERE t.rd = 1 AND si1.scustid = t.customerno
  434. );
  435. --更新官微积分
  436. UPDATE shanglifeecif.individual si SET si.officialCalculus = (
  437. SELECT temp.available_points FROM (SELECT t.available_points,t.certificate_no,row_number()OVER(PARTITION BY t.certificate_no ORDER BY t.gmt_created DESC) rd FROM t_account t) temp WHERE temp.rd = 1 AND temp.certificate_no = si.idcard
  438. );
  439. EXCEPTION
  440. WHEN HIVE_EXCEPTION THEN
  441. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  442. WHEN Others THEN
  443. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  444. END;
  445. /
  446. CREATE OR REPLACE PROCEDURE shanglifeecif.update_insuredinfo()
  447. IS
  448. BEGIN
  449. --更新被保人信息
  450. UPDATE shanglifeecif.individual a SET (
  451. ZIPCODE,--邮编
  452. HPhone,--电话
  453. PMPhone,--手机
  454. email, -- 邮箱
  455. RAL, --联系地址
  456. sobirth --省份
  457. ) = (
  458. SELECT
  459. t.zipcode,
  460. t.phone,
  461. t.mobile,
  462. t.email,
  463. regexp_replace(trim(t.address),'[0-9]','*') address,
  464. regexp_extract(t.address,'(.*?)省|(.*?)市',0) province
  465. FROM (
  466. SELECT
  467. row_number()OVER(PARTITION BY ls.customerno ORDER BY ls.modifydate desc) rn,
  468. ls.customerno,--客户号
  469. CASE
  470. WHEN ls.postaladdress IS NULL
  471. THEN
  472. CASE WHEN ls.homeaddress IS NULL THEN ls.companyaddress ELSE ls.homeaddress END
  473. ELSE ls.postaladdress
  474. END AS address,
  475. ls.phone,
  476. ls.zipcode,--邮编
  477. CASE WHEN ls.email IS NULL THEN ls.email2 ELSE ls.email END AS email,
  478. CASE WHEN ls.mobile IS NULL THEN ls.mobile2 ELSE ls.mobile END AS mobile
  479. FROM dsj.lcaddress ls
  480. ) t where t.rn = 1 AND t.customerno = a.scustid
  481. ) WHERE a.custtype = '被保人';
  482. UPDATE shanglifeecif.individual a SET (
  483. Height, --身高
  484. Weight, --体重
  485. BMI,
  486. PIncome, --个人年收入
  487. Ethnic, --民族情况
  488. Nation, --国籍
  489. MaritalStat, --婚姻
  490. Education,--学历
  491. SIStatus,--社保
  492. IncomeSource,--收入来源
  493. regtype --户籍类型
  494. ) = (
  495. SELECT
  496. t.stature,--身高
  497. t.avoirdupois,--体重
  498. t.bmi,
  499. t.yearincome,
  500. t.nationality,--民族
  501. t.nativeplace,--国籍
  502. t.marriage, --婚姻状况
  503. t.degree, --学历
  504. t.socialinsuflag,--社保
  505. t.incomesource,--收入来源
  506. t.dentype
  507. FROM (
  508. SELECT
  509. row_number()OVER(PARTITION BY ld.insuredno ORDER BY ld.modifydate desc) rn,
  510. ld.insuredno,--被保人客户号
  511. ld.appntno,--投保人客户号
  512. ld.name,--被保人名称
  513. ld.sex,--被保人性别
  514. ld.birthday,--被保人出生日期
  515. ld.idtype,--证件类型
  516. ld.idno,--证件号码
  517. ld.marriage,--婚姻状况
  518. ld.occupationtype,--职业
  519. ld.nativeplace,--国籍
  520. ld.nationality,--民族
  521. ld.stature,--身高
  522. ld.avoirdupois,--体重
  523. round((ld.avoirdupois/POWER((ld.stature/100),2)),2) bmi,
  524. ld.degree,--学历
  525. ld.worktype,--职业
  526. ld.dentype,--居民类型
  527. ld.socialinsuflag,--社保情况
  528. ld.incomesource,--收入来源
  529. ld.yearincome --年收入
  530. FROM dsj.lcinsured2 ld
  531. ) t WHERE t.rn = 1 AND t.insuredno = a.scustid
  532. ) WHERE a.custtype = '被保人';
  533. EXCEPTION
  534. WHEN HIVE_EXCEPTION THEN
  535. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  536. WHEN Others THEN
  537. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  538. END;
  539. /*
  540. CREATE OR REPLACE PROCEDURE shanglifeecif.up_health_insurance_listing_1() -- 创建存储过程
  541. IS
  542. BEGIN
  543. --更新个人信息表
  544. UPDATE shanglifeecif.individual a SET (
  545. OccupationId ,-- 职业代码
  546. Occupation, -- 职业名称
  547. HomeAdress
  548. ) = (
  549. SELECT
  550. t.appntoccupationcode,
  551. t.appntoccupationname,
  552. t.APPNTHOMEADDRESS
  553. FROM (
  554. select
  555. appntno,
  556. max(appntoccupationcode) appntoccupationcode,--职业代码
  557. max(appntoccupationname) appntoccupationname,--职业名称
  558. max(APPNTHOMEADDRESS) APPNTHOMEADDRESS --住址
  559. from HEALTH_INSURANCE_LISTING
  560. WHERE appntoccupationcode is not null
  561. and appntoccupationname is not NULL
  562. group by appntno
  563. ) t WHERE t.appntno = a.scustid
  564. );
  565. END;
  566. */
  567. BEGIN
  568. shanglifeecif.init_individual_main();
  569. end ;