Re: Using Transaction with if-else in prepared statement

Поиск
Список
Период
Сортировка
От hubert depesz lubaczewski
Тема Re: Using Transaction with if-else in prepared statement
Дата
Msg-id 20220525233556.GA9042@depesz.com
обсуждение исходный текст
Ответ на Using Transaction with if-else in prepared statement  (Hui Jackson <jackhts4@gmail.com>)
Ответы Re: Using Transaction with if-else in prepared statement
Список pgsql-sql
On Wed, May 25, 2022 at 07:12:49PM +0800, Hui Jackson wrote:
> I am trying to make transaction in nodejs
> The logic will be check if sufficient coin in sender's amount, if
> sufficient then do transaction.
> I am new to postgres, not sure if this is a right way to do so, if you have
> a better solution, please let me know, thank you.

I would do i by issuing *only*
INSERT INTO coin_history(sender_id, receiver_id, amount) VALUES
and then changing coin data with triggers plus adding constraints that
app_user.coin can never be < 0.

depesz



В списке pgsql-sql по дате отправления:

Предыдущее
От: Steve Midgley
Дата:
Сообщение: Re: Using Transaction with if-else in prepared statement
Следующее
От: Hui Jackson
Дата:
Сообщение: Re: Using Transaction with if-else in prepared statement