Change zip code column by inserting dash in Firebird

Asked

Viewed 1,120 times

1

I have a table of cities where I own the Zip Code.

The data looks like this: 89620000
I’d like to leave it at that: 89620-000

How can I do this in Firebird?

1 answer

3


You didn’t give a lot of details but I think this will solve:

UPDATE cidades SET cep = SUBSTRING(cep FROM 1 FOR 5) || "-" || SUBSTRING(cep FROM 6 FOR 8);

I put in the Github for future reference.

If the column had a size of 8 characters evidently you will have to increase it before.

Know that the most common is not to store penduricalhos in the data. In general the application or even darlings specific data should be treated neatly and hyphenated when necessary. Of course there are cases store everything may be necessary, it may be your case.

  • Well that’s what I needed. Thank you very much

  • Great example, I fully agree with this passage " In general the application or even specific queries should treat pure data and put the hyphen when necessary", +1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.