Saneamento da base do prestador — ProClinic
Estes são os comandos de SELECT
que podem ser executados no sistema da Senior, para facilitar a extração dos dados de colaboradores. Os dados extraídos devem ser usados para atualizar as informações dos respectivos colaboradores no sistema ProClinic.
Saneamento de dados:
Colaboradores
Ligação dos registros
A ligação dos registros é feita pelo código de integração do cadastro de Pessoas:
Registro no sistema da Senior | Registro no prestador SST |
---|---|
R030EMP.NumEmp
R034FUN.TipCol
R034FUN.NumCad
|
A partir das informações extraídas dos comandos SQL/Oracle, atualize as informações abaixo nos respectivos colaboradores no sistema do prestador:
|
Comandos do banco de dados para saneamento da base
SELECT R034FUN.NUMEMP 'Codigo Empresa Senior', CAST(R034FUN.TIPCOL AS VARCHAR(200)) 'Tipo colaborador', CAST(R034FUN.NUMCAD AS VARCHAR(200)) 'Matrícula', R034FUN.NomFun 'Nome Funcionário', R034FUN.CodFil 'Codigo Filial', R030FIL.NomFil 'Filial', CAST(R030ORG.TabOrg AS VARCHAR(200)) 'Tabela organograma Setor', CAST(R016HIE.CodLoc AS VARCHAR(200)) 'Codigo Setor', R016ORN.NomLoc 'Setor', CAST(R030CAR.EstCar AS VARCHAR(200)) 'Estrutura Cargo', CAST(R034FUN.CodCar AS VARCHAR(200)) 'Codigo Cargo', R024CAR.TitRed 'Cargo', CASE WHEN (convert(varchar, R034FUN.DatNas, 103) = '31/12/1900') THEN null ELSE (convert(varchar, R034FUN.DatNas, 103)) END 'Dt.Nascimento', CASE WHEN (convert(varchar, R034FUN.DatAdm, 103) = '31/12/1900') THEN null ELSE (convert(varchar, R034FUN.DatAdm, 103)) END 'Dt.Admissão', CASE WHEN (convert(varchar, R038AFA.DatAfa, 103) = '31/12/1900') THEN null ELSE (convert(varchar, R038AFA.DatAfa, 103)) END 'Dt.Demissão', CASE WHEN R034FUN.NumCPF = 0 THEN ' ' WHEN R034FUN.NumCPF IS NULL THEN ' ' WHEN ((R034FUN.NumCPF <> 0) AND (LEN(R034FUN.NumCPF)= 1)) THEN (SUBSTRING('0000000000' + CONVERT(CHAR, R034FUN.NumCPF),1,3) + '.' + SUBSTRING('0000000000' + CONVERT(CHAR, R034FUN.NumCPF),4,3) + '.' + SUBSTRING('0000000000' + CONVERT(CHAR, R034FUN.NumCPF),7,3) + '-' + SUBSTRING('0000000000' + CONVERT(CHAR, R034FUN.NumCPF),10,2)) WHEN ((R034FUN.NumCPF <> 0) AND (LEN(R034FUN.NumCPF)= 2)) THEN (SUBSTRING('000000000' + CONVERT(CHAR, R034FUN.NumCPF),1,3) + '.' + SUBSTRING('000000000' + CONVERT(CHAR, R034FUN.NumCPF),4,3) + '.' + SUBSTRING('000000000' + CONVERT(CHAR, R034FUN.NumCPF),7,3) + '-' + SUBSTRING('000000000' + CONVERT(CHAR, R034FUN.NumCPF),10,2)) WHEN ((R034FUN.NumCPF <> 0) AND (LEN(R034FUN.NumCPF)= 3)) THEN (SUBSTRING('00000000' + CONVERT(CHAR, R034FUN.NumCPF),1,3) + '.' + SUBSTRING('00000000' + CONVERT(CHAR, R034FUN.NumCPF),4,3) + '.' + SUBSTRING('00000000' + CONVERT(CHAR, R034FUN.NumCPF),7,3) + '-' + SUBSTRING('00000000' + CONVERT(CHAR, R034FUN.NumCPF),10,2)) WHEN ((R034FUN.NumCPF <> 0) AND (LEN(R034FUN.NumCPF)= 4)) THEN (SUBSTRING('0000000' + CONVERT(CHAR, R034FUN.NumCPF),1,3) + '.' + SUBSTRING('0000000' + CONVERT(CHAR, R034FUN.NumCPF),4,3) + '.' + SUBSTRING('0000000' + CONVERT(CHAR, R034FUN.NumCPF),7,3) + '-' + SUBSTRING('0000000' + CONVERT(CHAR, R034FUN.NumCPF),10,2)) WHEN ((R034FUN.NumCPF <> 0) AND (LEN(R034FUN.NumCPF)= 5)) THEN (SUBSTRING('000000' + CONVERT(CHAR, R034FUN.NumCPF),1,3) + '.' + SUBSTRING('000000' + CONVERT(CHAR, R034FUN.NumCPF),4,3) + '.' + SUBSTRING('000000' + CONVERT(CHAR, R034FUN.NumCPF),7,3) + '-' + SUBSTRING('000000' + CONVERT(CHAR, R034FUN.NumCPF),10,2)) WHEN ((R034FUN.NumCPF <> 0) AND (LEN(R034FUN.NumCPF)= 6)) THEN (SUBSTRING('00000' + CONVERT(CHAR, R034FUN.NumCPF),1,3) + '.' + SUBSTRING('00000' + CONVERT(CHAR, R034FUN.NumCPF),4,3) + '.' + SUBSTRING('00000' + CONVERT(CHAR, R034FUN.NumCPF),7,3) + '-' + SUBSTRING('00000' + CONVERT(CHAR, R034FUN.NumCPF),10,2)) WHEN ((R034FUN.NumCPF <> 0) AND (LEN(R034FUN.NumCPF)= 7)) THEN (SUBSTRING('0000' + CONVERT(CHAR, R034FUN.NumCPF),1,3) + '.' + SUBSTRING('0000' + CONVERT(CHAR, R034FUN.NumCPF),4,3) + '.' + SUBSTRING('0000' + CONVERT(CHAR, R034FUN.NumCPF),7,3) + '-' + SUBSTRING('0000' + CONVERT(CHAR, R034FUN.NumCPF),10,2)) WHEN ((R034FUN.NumCPF <> 0) AND (LEN(R034FUN.NumCPF)= 8)) THEN (SUBSTRING('000' + CONVERT(CHAR, R034FUN.NumCPF),1,3) + '.' + SUBSTRING('000' + CONVERT(CHAR, R034FUN.NumCPF),4,3) + '.' + SUBSTRING('000' + CONVERT(CHAR, R034FUN.NumCPF),7,3) + '-' + SUBSTRING('000' + CONVERT(CHAR, R034FUN.NumCPF),10,2)) WHEN ((R034FUN.NumCPF <> 0) AND (LEN(R034FUN.NumCPF)= 9)) THEN (SUBSTRING('00' + CONVERT(CHAR, R034FUN.NumCPF),1,3) + '.' + SUBSTRING('00' + CONVERT(CHAR, R034FUN.NumCPF),4,3) + '.' + SUBSTRING('00' + CONVERT(CHAR, R034FUN.NumCPF),7,3) + '-' + SUBSTRING('00' + CONVERT(CHAR, R034FUN.NumCPF),10,2)) WHEN ((R034FUN.NumCPF <> 0) AND (LEN(R034FUN.NumCPF)= 10)) THEN (SUBSTRING('0' + CONVERT(CHAR, R034FUN.NumCPF),1,3) + '.' + SUBSTRING('0' + CONVERT(CHAR, R034FUN.NumCPF),4,3) + '.' + SUBSTRING('0' + CONVERT(CHAR, R034FUN.NumCPF),7,3) + '-' + SUBSTRING('0' + CONVERT(CHAR, R034FUN.NumCPF),10,2)) WHEN ((R034FUN.NumCPF <> 0) AND (LEN(R034FUN.NumCPF)= 11)) THEN (SUBSTRING(CONVERT(CHAR, R034FUN.NumCPF),1,3) + '.' + SUBSTRING(CONVERT(CHAR, R034FUN.NumCPF),4,3) + '.' + SUBSTRING(CONVERT(CHAR, R034FUN.NumCPF),7,3) + '-' + SUBSTRING(CONVERT(CHAR, R034FUN.NumCPF),10,2)) ELSE '' END 'CPF', R033PES.NumCid 'RG', R033PES.EstCid 'UF-RG' FROM R034FUN inner join R030EMP on (R030EMP.NumEmp = R034FUN.NumEmp) inner join R030CAR on (R030CAR.NumEmp = R034FUN.NumEmp AND R030CAR.EstCar = R034FUN.EstCar AND R030CAR.DatAlt = (SELECT MAX(C.DATALT) FROM R030CAR C WHERE R030EMP.NumEmp = C.NumEmp AND C.DatAlt <= GETDATE())) inner join R024CAR on (R024CAR.EstCar = R034FUN.EstCar AND R024CAR.CodCar = R034FUN.CodCar) inner join R030ORG on (R030ORG.NumEmp = R034FUN.NumEmp AND R030ORG.TabOrg = R034FUN.TabOrg AND R030ORG.DatAlt = (SELECT MAX(O.DATALT) FROM R030ORG O WHERE R030EMP.NumEmp = O.NumEmp AND O.DatAlt <= GETDATE())) inner join R016ORN on (R016ORN.TabOrg = R034FUN.TabOrg AND R016ORN.NumLoc = R034FUN.NumLoc) inner join R016HIE on (R016HIE.TabOrg = R034FUN.TabOrg AND R016HIE.NumLoc = R034FUN.NumLoc AND R016HIE.DatIni = (SELECT MAX(H.DATINI) FROM R016HIE H WHERE R034FUN.TabOrg = H.TabOrg AND R034FUN.NumLoc = H.NumLoc AND H.DatIni <= GETDATE())) inner join R030FIL on (R030FIL.NumEmp = R034FUN.NumEmp AND R030FIL.CodFil = R034FUN.CodFil) inner join R010SIT on (R010SIT.CodSit = R034FUN.SitAfa) left join R033PES on (R033PES.CodPES = R034FUN.CodPes) left join R038AFA on (R038AFA.numemp = R034FUN.NumEmp AND R038AFA.TipCol = R034FUN.tipcol AND R038AFA.NumCad = R034FUN.numcad AND r038afa.sitafa in (SELECT S.codsit FROM r010sit S WHERE S.tipsit = 7)) WHERE R034FUn.tipcol IN (1,2) ORDER BY 1,3,4 |
SELECT R034FUN.NumEmp "Codigo Empresa Senior", R034FUN.TipCol "Tipo colaborador", R034FUN.NumCad "Matrícula", R034FUN.NomFun "Nome Funcionário", R034FUN.CodFil "Codigo Filial", R030FIL.NomFil "Filial", R030ORG.TabOrg "Tabela organograma Setor", R016HIE.CodLoc "Codigo Setor", R016ORN.NomLoc "Setor", R030CAR.EstCar "Estrutura Cargo", R034FUN.CodCar "Codigo Cargo", R024CAR.TitRed "Cargo", DECODE(TO_CHAR(R034FUN.DatNas, 'DD/MM/YYYY'), '31/12/1900', null, TO_CHAR(R034FUN.DatNas, 'DD/MM/YYYY')) "Dt.Nascimento", DECODE(TO_CHAR(R034FUN.DatAdm, 'DD/MM/YYYY'), '31/12/1900', null, TO_CHAR(R034FUN.DatAdm, 'DD/MM/YYYY')) "Dt.Admissão", DECODE(TO_CHAR(R038AFA.DATAFA, 'DD/MM/YYYY'), '31/12/1900', null, TO_CHAR(R038AFA.DATAFA, 'DD/MM/YYYY')) "Dt.Demissão", DECODE(R034FUN.NumCPF, 0, ' ', SUBSTR(TO_CHAR(R034FUN.NumCPF),1,3) ||'.'|| SUBSTR(TO_CHAR(R034FUN.NumCPF),4,3) ||'.'|| SUBSTR(TO_CHAR(R034FUN.NumCPF),7,3) ||'-'|| SUBSTR(TO_CHAR(R034FUN.NumCPF),10,2)) "CPF", R033PES.NumCid "RG", R033PES.EstCid "UF-RG" FROM R034FUN inner join R030EMP on (R030EMP.NumEmp = R034FUN.NumEmp) inner join R030CAR on (R030CAR.NumEmp = R030EMP.NumEmp AND R030CAR.EstCar = R034FUN.EstCar AND R030CAR.DatAlt = (SELECT MAX(DATALT) FROM R030CAR C WHERE R030EMP.NumEmp = C.NumEmp AND C.DatAlt <= SYSDATE)) inner join R024CAR on (R024CAR.EstCar = R034FUN.EstCar AND R024CAR.CodCar = R034FUN.CodCar) inner join R030ORG on (R030ORG.NumEmp = R034FUN.NumEmp AND R030ORG.TabOrg = R034FUN.TabOrg AND R030ORG.DatAlt = (SELECT MAX(O.DATALT) FROM R030ORG O WHERE R030EMP.NumEmp = O.NumEmp AND O.DatAlt <= SYSDATE)) inner join R016ORN on (R016ORN.TabOrg = R034FUN.TabOrg AND R016ORN.NumLoc = R034FUN.NumLoc) inner join R016HIE on (R016HIE.TabOrg = R034FUN.TabOrg AND R016HIE.NumLoc = R034FUN.NumLoc AND R016HIE.DatIni = (SELECT MAX(DATINI) FROM R016HIE H WHERE R034FUN.TabOrg = H.TabOrg AND R034FUN.NumLoc = H.NumLoc AND H.DatIni <= SYSDATE)) inner join R030FIL on (R030FIL.NumEmp = R034FUN.NumEmp AND R030FIL.CodFil = R034FUN.CodFil) inner join R010SIT on (R010SIT.CodSit = R034FUN.SitAfa) left join R033PES on (R033PES.CodPES = R034FUN.CodPes) left join R038AFA on (R038AFA.numemp = R034FUN.NumEmp AND R034FUN.TipCol = R038AFA.tipcol AND R034FUN.NumCad = R038AFA.numcad AND r038afa.sitafa IN (SELECT codsit FROM r010sit WHERE r010sit.tipsit = 7)) WHERE R034FUN.TipCol IN (1,2) ORDER BY 1,3,4 |
Observação
O comando acima considera também os colaboradores que estão demitidos.