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
I need to do it using a SQL Transaction. Thank you in advance if you can show or point me to the right direction. I am very newbie in PostgreSql.