Error handling: Resume work after error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Error handling: Resume work after error

Raul Kaubi
Hi

PostgreSQL 12.1

Let's say I want my procedure/function to resume work after specific error ( duplicate_table ).
Is it possible to resume work after error..?


EXCEPTION
WHEN duplicate_table then ......;

Or is there different approach to achieve that..?


Thanks
Raul 
Reply | Threaded
Open this post in threaded view
|

Re: Error handling: Resume work after error

hubert depesz lubaczewski-2
On Wed, Feb 05, 2020 at 04:17:09PM +0200, Raul Kaubi wrote:
> Let's say I want my procedure/function to resume work after specific error
> ( duplicate_table ).
> Is it possible to resume work after error..?
> EXCEPTION
> > WHEN duplicate_table then ......;

Sure you can:

https://www.postgresql.org/docs/current/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

Best regards,

depesz



Reply | Threaded
Open this post in threaded view
|

Re: Error handling: Resume work after error

Raul Kaubi
Oh yeah, I must add new begin ... exception .. end; block between.

So like this:

BEGIN
 
BEGIN
EXCEPTION when ..... then ..
END;

END;

At first I did like this:

BEGIN
..... 
EXCEPTION when ..... then ..;
END;  

Raul

Kontakt hubert depesz lubaczewski (<[hidden email]>) kirjutas kuupäeval K, 5. veebruar 2020 kell 17:03:
On Wed, Feb 05, 2020 at 04:17:09PM +0200, Raul Kaubi wrote:
> Let's say I want my procedure/function to resume work after specific error
> ( duplicate_table ).
> Is it possible to resume work after error..?
> EXCEPTION
> > WHEN duplicate_table then ......;

Sure you can:

https://www.postgresql.org/docs/current/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

Best regards,

depesz