PARA OS FERAS - CONCATENAR VALORES

Firebird

31/03/2003

SELECT CAMPO1||CAMPO2 FROM TABELA

SE O CAMPO1 ESTIVER NULO O RESULTADO SERÁ NULO.
COMO FAZER PARA RETORNA O VALOR DO CAMPO2 ???


Anonymous

Anonymous

Curtidas 0

Respostas

Anonymous

Anonymous

31/03/2003

SELECT CAMPO1||CAMPO2 FROM TABELA SE O CAMPO1 ESTIVER NULO O RESULTADO SERÁ NULO. COMO FAZER PARA RETORNA O VALOR DO CAMPO2 ???


Vc já tentou algo com union?? Veja:

select campo1 || campo2 from tabela
where (not campo1 is null)
union
select CAST(campo2 as VARCHAR( TAM_CAMPO1 + TAM_CAMPO 2) from tabela
where (campo1 is null)

onde TAM_CAMPO1 e TAM_CAMPO2 tamanho dos campos 1 e 2 respec.

Isso deve funcionar, mas com certeza nao é coisa muito agradável. Sugiro dar uma olhada em UDFs.


GOSTEI 0
POSTAR