0

I have 2 separate databases. I need to select record from first database, then parse it to the right format, then save to second db and then if save was succeeded, i need to update "isSaved" flag in first database for this row. How can i do this right via nodejs? Or maybe there is some kind of "shared transaction" between 2 db?

1 Answers1

0

PostgreSQL supports distributed transactions (named two-phase commit in the documentation): this feature allows to run different statements in different databases in one single transaction.

Distributed transactions are managed with PREPARE TRANSACTION, COMMIT PREPARED and ROLLBACK PREPARED specifc statements (instead of BEGIN/COMMIT/ROLLBACK for non-distributed transactions).

See also How to process distributed transaction within postgresql?

pifor
  • 7,419
  • 2
  • 8
  • 16