Como substituir cedilha (ç) por C
BOM PESSOAL É O SEGUINTE, ESTOU FAZENDO UMA MIGRAÇÃO DE UM BANCO .GDB PRA UMA TABELA EM .DBF E ESTOU ENCONTRANDO O SEGUINTE PROBLEMA NA HORA DA MIGRAÇÃO. NA TABELA .GDB NO CADASTRO DE PRODUTOS EXISTEM ALGUNS PRODUTOS CADASTRADOS COM Ç (EXEM: MAÇA) E NA HORA DA MIGRAÇÃO QUANDO CHEGA NESTES PRODUTOS QUE NA DESCRIÇÃO TEM O 'Ç' DA ERRO. GOSTARIA DE SABER COMO EU PODERIA SUBSTITUIR NA TABELA .GDB O Ç POR C, PRA QUE NA HORA DA MIGRAÇÃO NÃO TENHA ESTES ERROS.
DESDE JÁ AGRADEÇO A VOSSA PRECIOSA AJUDA.
DESDE JÁ AGRADEÇO A VOSSA PRECIOSA AJUDA.
Francisco Vasconcelos
Curtidas 0
Respostas
William
28/08/2012
Colega uma idéia inicial seria vc usar a função REPLACE(CAMPO, 'Ç', 'C'), só que vc tem q informar qual campo quer executar o replace, no seu caso seria legal usar um for select parar percorrer todos os registros.
Bom essa foi uma idéia inicial...
Bom essa foi uma idéia inicial...
GOSTEI 0
Francisco Vasconcelos
28/08/2012
valeu pela dica, mas só lembrando que a alteração tem que ser feita no banco firebird.
GOSTEI 0
Deivison Melo
28/08/2012
Veja se essa procedure ajuda vc:
Como tirar acentos, adapte as tuas necessidades.
SET TERM ^ ;
CREATE OR ALTER PROCEDURE TIRA_ACENTOS (
dado varchar(512) = '')
returns (
retorno varchar(512))
as
declare variable com_acento varchar(40) = 'àâêôûãõáéíóúçüÀÂÊÔÛÃÕÁÉÍÓÚÇÜÑñ';
declare variable sem_acento varchar(40) = 'aaeouaoaeioucuAAEOUAOAEIOUCUNn';
declare variable letra varchar(1) = '';
begin
RETORNO = '';
While (DADO<>'') do
begin
Select case substring(:DADO from 1 for 1)
when 'à' then
'a'
when 'â' then
'a'
when 'ã' then
'a'
when 'á' then
'a'
when 'À' then
'A'
when 'Ã' then
'A'
when 'Á' then
'A'
when 'ê' then
'e'
when 'é' then
'e'
when 'Ê' then
'e'
when 'É' then
'E'
when 'ô' then
'o'
when 'õ' then
'o'
when 'ó' then
'o'
when 'Ô' then
'O'
when 'Ó' then
'O'
when 'Õ' then
'O'
when 'û' then
'u'
when 'ú' then
'u'
when 'ü' then
'u'
when 'Û' then
'U'
when 'Ú' then
'U'
when 'Ü' then
'U'
when 'í' then
'i'
when 'Í' then
'I'
when 'ç' then
'c'
when 'Ç' then
'C'
when 'ñ' then
'n'
when 'Ñ' then
'N'
else
substring(:DADO from 1 for 1)
end
from rdb$database into :LETRA;
RETORNO = RETORNO || LETRA;
DADO = substring(DADO from 2 for 512);
end
suspend;
end^
SET TERM ; ^
http://permalink.gmane.org/gmane.comp.db.firebase.portuguese/91948
Como tirar acentos, adapte as tuas necessidades.
SET TERM ^ ;
CREATE OR ALTER PROCEDURE TIRA_ACENTOS (
dado varchar(512) = '')
returns (
retorno varchar(512))
as
declare variable com_acento varchar(40) = 'àâêôûãõáéíóúçüÀÂÊÔÛÃÕÁÉÍÓÚÇÜÑñ';
declare variable sem_acento varchar(40) = 'aaeouaoaeioucuAAEOUAOAEIOUCUNn';
declare variable letra varchar(1) = '';
begin
RETORNO = '';
While (DADO<>'') do
begin
Select case substring(:DADO from 1 for 1)
when 'à' then
'a'
when 'â' then
'a'
when 'ã' then
'a'
when 'á' then
'a'
when 'À' then
'A'
when 'Ã' then
'A'
when 'Á' then
'A'
when 'ê' then
'e'
when 'é' then
'e'
when 'Ê' then
'e'
when 'É' then
'E'
when 'ô' then
'o'
when 'õ' then
'o'
when 'ó' then
'o'
when 'Ô' then
'O'
when 'Ó' then
'O'
when 'Õ' then
'O'
when 'û' then
'u'
when 'ú' then
'u'
when 'ü' then
'u'
when 'Û' then
'U'
when 'Ú' then
'U'
when 'Ü' then
'U'
when 'í' then
'i'
when 'Í' then
'I'
when 'ç' then
'c'
when 'Ç' then
'C'
when 'ñ' then
'n'
when 'Ñ' then
'N'
else
substring(:DADO from 1 for 1)
end
from rdb$database into :LETRA;
RETORNO = RETORNO || LETRA;
DADO = substring(DADO from 2 for 512);
end
suspend;
end^
SET TERM ; ^
http://permalink.gmane.org/gmane.comp.db.firebase.portuguese/91948
GOSTEI 0
Francisco Vasconcelos
28/08/2012
Valeu Deivison, vou testar aqui...
GOSTEI 0
William
28/08/2012
Colega a função REPLACE é do Firebird mesmo, pode usá-la no IBExpert ou qualquer outra ferramenta de gerenciamento sem problemas..
GOSTEI 0