I'm new to SQL and I have the following problem.
I want to sum total number of errors that are reaching my device.
So, suppose I have inside my_table variables with names SeqErr and TotalSeqErr.
I initialized them to 0 and verified it, but when I do the following:
UPDATE my_table
SET
...
SeqErr = COALESCE(SeqErr, 0) + 1,
TotalSeqErr = SeqErr,
...
I see that when I retrieve this table it is coming with the following values:
SeqErr = 1 , TotalSeqErr = 0 (i.e. SeqErr was updated but TotalSeqErr is using old SeqErr value instead of updated one).
How can I solve this issue?
Note: Probably there is issue similar to mine here but I couldn't find one.
PostgreSQLas my SQL database if this is what you meant.coalesce()) dbfiddle.uk/…seqerris not a "variable", it's called a column