It’s very simple, turn the column into a numeric type.
Use text for descriptive columns, even if you only have numeric digits in it. And use numeric columns when you need to do accounts, like this.
It’s even possible to do it this way, but it’s so much more complicated that the ideal is to change the spine. Don’t work with misconceptions that the problem gets bigger and bigger.
If you insist you will need first of all to convert the column to numeric, make the account summing 1 and then convert again to text.
UPDATE produto SET codigo = to_char(to_number(codigo, '999999') + 1);
I put in the Github for future reference.
But this may vary according to your need.
Understand the difference between what is the data, what is the column, the syntax, what does everything in the code. Without understanding what each thing does in your code you won’t be able to program. And this is the easy part of programming. You have no idea the hard part. And how easy it is to do everything wrong and work and think you’re getting some result, when you’re causing huge problems.
the way you described you are concatenating the string code with 1.. would then have 'code 1' save at the bank. That’s what you want?
– rLinhares
no friend, I actually need to add the existing value you understand, like I have code 361 and I want it to add +1. and repeat this for all codes..
– Erenilson Alencastro
I think it is not very clear, but it may be related to: https://answall.com/a/31633/69359 and https://answall.com/a/296101/69359
– Rovann Linhalis
@Erenilsonalencastro Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already done so. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site (when you have enough score).
– Maniero