Daniel L. VanDenBosch
Daniel L. VanDenBosch

Reputation: 2725

PostgreSQL plpgsql try catch block equivalent

I am using PostgreSQL 9.6.

I have a PROCEDURE in sql server. That makes use of a try catch block. It looks a little bit like the code below:

        BEGIN TRANSACTION
        BEGIN TRY
        --do stuff here
        COMMIT TRANSACTION
        END TRY
        BEGIN CATCH
        ROLLBACK TRANSACTION
        --do error stuff here
        END CATCH

Upon doing some research, It seems like postgres does not make use of try catch. Is there some way to handle this in postgres the same way sql server does?

Upvotes: 9

Views: 16989

Answers (0)

Related Questions