In this post, I will tell you how to fix the error that PostgreSQL throws when you try to execute an SQL-statement.
When you execute a non-correct SQL statement, you correct it and try to execute it again, you can have an error like: ERROR: current transaction is aborted, commands ignored until end of transaction block
By executing that wrong SQL-statement, postgreSQL will not terminate the execution by itself so you need to rollback manually. You can do this by simply execute the following statement:
rollback;
Example
I want to execute the non-correct SQL-statement:
select * from account
PostgreSQL will throw the following error: syntax error at or near ‘fro’. This means my word ‘from’ is not correctly typed. So I now want to execute the correct statement:
select * from account
Here, PostgreSQL will throw the following error: current transaction is aborted, commands ignored until end of transaction block. This is because the wrong SQL-statement is still trying to commit. Now, to rollback, type the following SQL-statement:
rollback;
Now we can try to execute the correct SQL-statement again. You will notice that it works this time. Enjoy 😀
Awesome!!! It really helped me!!
Awesome ‘rollback’ command really helped me. Thank you Guys…Cheers 🙂
[…] Source: https://laurenthinoul.com/how-to-fix-postgres-error-current-transaction-is-aborted-commands-ignored-… […]