Sp1 Sp1 - 9 days ago 6
Java Question

how to perform operations in queries programatically?

How to do the operation

w_balance = w_balance + amount
in the query String? One way is to perform the operation outside the Query String. But is there a way to do that directly? Here,
amount
is the new amount I would want to add or subtract from the
w_balance
.

My database is postgresql.

String SQL = "update walletapp.users_acc set w_balance = w_balance + amount where kyc_id = :sender_id";


I used -
String SQL = "update walletapp.users_acc set w_balance = w_balance + :amount where kyc_id = :sender_id";
which solved my problem.

Sp1 Sp1
Answer

As indicated by @a_horse_with_no_name set w_balance = w_balance + :amount worked for me.