Re: No return from trigger function

Поиск
Список
Период
Сортировка
От James B. Byrne
Тема Re: No return from trigger function
Дата
Msg-id 45335.216.185.71.24.1239221958.squirrel@webmail.harte-lyne.ca
обсуждение исходный текст
Ответ на Re: No return from trigger function  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Wed, April 8, 2009 16:06, Tom Lane wrote:
> "James B. Byrne" <byrnejb@harte-lyne.ca> writes:
>> I just need another set of eyes to see whatever it is that I am
>> overlooking.
>
> The RETURN is inside the EXCEPTION clause.
>
> You really need two BEGINs here, one for the outer function body and
> one for the exception block around the INSERT.
>
>             regards, tom lane
>

So, something like:

CREATE OR REPLACE FUNCTION hll_pg_fn_ident_insert()
      RETURNS TRIGGER AS $pg_fn$
        -- ROW AFTER TRIGGER
        -- trigger passes identifier_type and _description
        -- received as ARGV[0] and ARGV[1]
      BEGIN
        BEGIN
          INSERT INTO identifiers(...
          ...
        EXCEPTION
          WHEN ....
        END;
      RETURN NULL:
      END;

--
***          E-Mail is NOT a SECURE channel          ***
James B. Byrne                mailto:ByrneJB@Harte-Lyne.ca
Harte & Lyne Limited          http://www.harte-lyne.ca
9 Brockley Drive              vox: +1 905 561 1241
Hamilton, Ontario             fax: +1 905 561 0757
Canada  L8E 3C3


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

Предыдущее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: No return from trigger function
Следующее
От: Tom Lane
Дата:
Сообщение: Re: some external sql not working in psql