I wanna create a triger function to feed a column with a value generated from a concatenation of two other columns with predetermined values. If the value alredy exist i would add a int to the concatanation.
EX:
column1 -> 'aaa'
column2 -> 'bbb'
concated value -> 'aaabbb'
if there's already rows with the values 'aaabbb' and 'aaabbb1', add a int to the value -> 'aaabbb3'.
All the three columns are the type text.
I image the sql would be something like this:
UPDATE formulario.formulario_projetos
SET repid = concat(distrito, tipo_ep, SELECT COUNT(repid));