How to remove the last character of a field in Firebird SQL

2

I have a field in a table that should only contain 4 characters, I noticed that it is 5 characters and the last one is the number zero.

Example:

Código Errado: 45380
Código Correto = 4538

Can you delete the last character of a field in Firebird SQL?

    
asked by anonymous 31.03.2016 / 02:30

3 answers

1

You can use CHARACTER_LENGTH :

UPDATE minhaTabela
SET    minhaColuna = Substring(minhaColuna FROM 1 FOR 4)
WHERE  Character_length(minhaColuna) = 5  

In this way, only the last one will be removed.

    
31.03.2016 / 14:49
0

Just do a UPDATE by dividing the value by 10.

update minhaTabela
set Campo = Campo/10
where [...]
    
31.03.2016 / 02:43
0

Have you tried using the strlen method?

   UPDATE suatabel SET campo = SUBSTR(campo , 1, strlen(campo)-1)
    where strlen(campo) = 5;
    
31.03.2016 / 14:06