According to Postgres documentation. After it has been prepared, the transaction can later be completed or rolled back with PREPARED PREPARATIONS or PREPARED ROLLB, respectively. These commands can be issued from any session, not only the one that executed the original transaction.
I am trying to import data from csv into database tables, and for this I use
COPY tablename [ ( column [, ...] ) ] FROM { 'filename' }
all this is done in a shell script. Now the problem is that I execute the psql and pass this command as a parameter via the -c option (I start the transaction with the command
prepare transaction 'some-id' in this command).
I want to create a Savepoint and roll back any errors to it.
After several other tasks in the shell script, I check for the errors that the previous psql statement produced, and when I then try to rollback using the command
Prepared Rollback 'transaction-id' (in a separate psql command with sql statements )
Reported as " No "transaction-id" found "
Am I getting the concept wrong or is something missing in the process?
Is this because I issue the psql several times, and each of them leads to a new transaction?
source share