D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
crsys
/
Filename :
correção_gre_funcionarios_CPF_Telefones.sql
back
Copy
use crsys; truncate table crsys.gre_funcionarios; insert into crsys.gre_funcionarios (SELECT codigo, empregador, case when empregador = 'M BLANC COMÉRCIO DE PEDRA EIRELI – EPP' then 1 when empregador = 'MB comércio de pedras e materiais p/ construção Ltda' then 2 when empregador = 'Mont Blanc comércio de pedras Ltda' then 1 when empregador = 'SR Marmoraria' then 1 else 1 end, nome, case when sexo = 'M' then 1 when sexo = 'F' then 2 else null end sexo_id, admissao, demissao, rg, REGEXP_REPLACE(cpf, '[^0-9]', '') cpf, ctps, pis, DataNascimento, case when estadocivil = 'Casado' then 1 when estadocivil = 'Casada' then 1 when estadocivil = 'Divorciada' then 2 when estadocivil = 'Divorciado' then 2 when estadocivil = 'Divorcido' then 2 when estadocivil = 'Solteira' then 3 when estadocivil = 'Solteiro' then 3 when estadocivil = 'Soltero' then 3 when estadocivil = 'Soltetiro' then 3 when estadocivil = 'Soteiro' then 3 when estadocivil = 'Souteiro' then 3 when estadocivil = 'amasiado' then 4 when estadocivil = 'União Estável' then 4 when estadocivil = 'Viúva' then 5 when estadocivil = 'Viuvo' then 5 when estadocivil = 'Outro' then 6 when estadocivil = 'Outros' then 6 else null end estado_civil, conjuge, funcao, null, REGEXP_REPLACE(cep, '[^0-9]', '') cep, REGEXP_REPLACE(telres, '[^0-9]', '') fone_fixo, REGEXP_REPLACE(celular, '[^0-9]', '') celular, endereco, numero, bairro, null, cidade, null, encarregado, null, Alimentacao, null, vt, detalhevt, null, indicacao, null, DadosBancario, 1, case when departamento = 'Admin' then 11 when departamento = 'Apoio' then 11 when departamento = 'Administrativo' then 11 when departamento = 'Colocação' then 6 when departamento = 'Compras' then 7 when departamento = 'Controle de Acesso' then 11 when departamento = 'Cozinha' then 8 when departamento = 'Diretoria' then 1 when departamento = 'Expedição' then 9 when departamento = 'Financeiro' then 10 when departamento = 'Limpeza' then 12 when departamento = 'Produção' then 5 when departamento = 'Projetos' then 4 when departamento = 'Recepção' then 11 when departamento = 'RH' then 10 when departamento = 'Vendas' then 2 else null end area_id, case when Status = 'Ativo' then 1 when Status = 'Inativo' then 2 else null end gre_sit_id, now(), 1, null, null, email, null, null, ltrim(obs) FROM dados_mont_blanc.tbllogin where tipo = 'Funcionario'); -- após comandos acima rodar o http://localhost/crsys/checa_cpf_func.php para detectar cpf errado -- resultado Validação concluída. # id, nome, datainicio, demissão, cpf_errado '2', 'Arivaldo Soares da Silva', '2013-05-06', NULL, '208.127.235-72' -- Beneficiamento truncate crsys.gre_beneficiamentos; insert into crsys.gre_beneficiamentos SELECT codigo, beneficiamento,(valor/100),1,1,now(),1,null,null FROM dados_mont_blanc.tblbeneficiamento;