I need to fetch data from my laptop (Postgresql) and insert that to the main server (in a different machine) using also a PostgreSQL. In MSSQL I normally do this:
- BEGIN TRY
- BEGIN TRANSACTION
- INSERT Main_Server.databasename.tbltransactions
- SELECT * FROM Local_Server.databasename.tbltransactions
- WHERE synchronized IS NULL
- UPDATE Local_Server.databasename.tbltransactions SET synchronized = GETDATE() WHERE synchronized IS NULL
- COMMIT TRANSACTION
- END TRY
- BEGIN CATCH
- ROLLBACK TRANSACTION
- RAISERROR('There was a problem connecting to the server database. The connection was lost.',16,1)
- END CATCH


Jefferson S. MottaRank #207 · 11.7K reputationPosted Jul 14, 2020, 5:07 AM EDT
Jes SieRank #1,285 · 1.3K reputationPosted Jul 14, 2020, 5:18 AM EDT
Jefferson S. MottaRank #207 · 11.7K reputationPosted Jul 14, 2020, 7:30 AM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Jul 14, 2020, 6:29 PM EDT