CREATE OR REPLACE PROCEDURE shanglifeecif.insuranceclaimthread_main() -- �������洢����
IS    
BEGIN
	insert into shanglifeecif.insuranceclaimthread (
		icthreadid ,--'��������Id',1
		crno ,--'������',2
		--companyno ,-- '��˾����',
		policyno ,--'���յ��� INSURANCE_CLAIM.CONTNO',3
		--applicantid ,--'Ͷ����ID',
		--appname ,--'Ͷ��������',
		--appphone ,--'Ͷ�����ֻ�',
		--appcertid ,--'Ͷ����֤������ INSURANCE_CLAIM.RISKDATE',
		cnno ,--'������',4
		losstime ,-- '��ʧ����ʱ��',5
		--rpid ,-- '������',
		rpname ,--'����������',6
		--rpphone ,-- '�����˵绰',
		--lpid ,--'������	����INSURANCE_CLAIM.INSUREDNO��ȡindid',
		lpscutid,--'���������οͻ���7
		lpname ,-- '����������',
		cndate ,--'�������� INSURANCE_CLAIM.RPTDATE',
		lossdescribe ,-- '��ʧԭ�� ����������ԭ��:INSURANCE_CLAIM.LLOCCURREASON',
		crdate ,-- '�������� INSURANCE_CLAIM.RGTDATE',
		cndescribe ,--'�������� INSURANCE_CLAIM.ACCIDENTDETAIL',
		claimstatus ,--'����״̬ ������״̬�����磺¼�롢��������',
		csdate ,--'����״̬����',
		relationship ,-- '������������˹�ϵ',
		ccno ,-- '�ⰸ�� AUDIT_CLAIM_INSURANCE.CLMNO',
		ccstatus ,--'�ⰸ״̬',
		--ccsdate ,-- '�ⰸ״̬����',
		productid ,--'���ִ���	INSURANCE_CLAIM_HEALTH.RISKCODE',
		productname, --'��������	INSURANCE_CLAIM_HEALTH.RISKNAME',
		ccamt ,--'�⸶���	INSURANCE_CLAIM_HEALTH.realpay',
		--branchcode,-- '��������',
		claimcasestatus ,--'����״̬INSURANCE_CLAIM_HEALTH.LLCLAIMSTATE',
		accidenttype,
		created_by ,
		created_time 
		-- updated_time,
		-- updated_by
	) select 
   		row_number()over(),--1
   		rgtno,--2
		contno,--3
		rptno,--������4
		riskdate,--��ʧ������ʱ��5
		rptorname,--����������6
   		INSUREDNO,--������ ���οͻ���
   		INSUREDNAME,
		rptdate,
		lloccurreason,
		rgtdate,
		accidentdetail,--��������
		llclaimstate,
		auditdate,--��������
		relation,
		clmno,--�ⰸ��
		llgettype,--�ⰸ״̬
		riskcode,
		riskname,
		realpay,
		llclaimstate,--����״̬
		accidenttype,
		'admin',
		sysdate()
	from shanghailifeecif.INSURANCE_CLAIM where contno is not null 

	/*UPDATE shanglifeecif.insuranceclaimthread a SET (
			applicantid ,--'Ͷ����ID',
			appname ,--'Ͷ��������',
			appphone ,--'Ͷ�����ֻ�',
			appcertid, --'Ͷ����֤������ INSURANCE_CLAIM.RISKDATE',
			branchcode-- '��������',
		) = (
		
			SELECT 
				temp.applicantid ,--'Ͷ����ID',
				temp.appname ,--'Ͷ��������',
				temp.appphone ,--'Ͷ�����ֻ�',
				temp.appcertid, --'Ͷ����֤������ INSURANCE_CLAIM.RISKDATE',
				temp.branchcode-- '��������',
			FROM (
				select 
				row_number() over(partition by applicantid) rn,
				applicantid ,--'Ͷ����ID',
				appname ,--'Ͷ��������',
				appphone ,--'Ͷ�����ֻ�',
				appcertid, --'Ͷ����֤������ INSURANCE_CLAIM.RISKDATE',
				branchcode,-- '��������',
				policyno
			from shanglifeecif.insurancearrangement b
			--where b.policyno  = a.policyno
			
			) temp WHERE temp.policyno = a.policyno AND temp.rn = 1);
*/
END;