Re: Commit and Exception Block

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Commit and Exception Block
Дата
Msg-id 231422.1633705396@sss.pgh.pa.us
обсуждение исходный текст
Ответ на RE: Commit and Exception Block  (<soumik.bhattacharjee@kpn.com>)
Список pgsql-admin
<soumik.bhattacharjee@kpn.com> writes:
> I have a procedure that may encounter an exception. I want to have an exception handling block where exception is to
catchis any FK violations. 
> Could you please suggest where it's getting missed as part of a transaction.

I think you're confused about the scope of the exception block.
The syntax is

    BEGIN
      some code here that might throw an exception
    EXCEPTION
      some WHEN clauses here to catch exceptions from the covered code
    END

You wrote:

>    begin
>     RAISE SQLSTATE 'MYERR';
>       EXCEPTION
>       WHEN ...

So this exception block can *only* trap errors arising from that one
RAISE command, not anything earlier in the procedure.  Seems unlikely
that's what you wanted.

            regards, tom lane



В списке pgsql-admin по дате отправления:

Предыдущее
От:
Дата:
Сообщение: RE: Commit and Exception Block
Следующее
От: Tim
Дата:
Сообщение: Logical Replication Sync - Issue with Table Bloat