Search Postgresql Archives

Re: No return from trigger function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, April 8, 2009 16:05, hubert depesz lubaczewski wrote:
> On Wed, Apr 08, 2009 at 03:59:22PM -0400, James B. Byrne wrote:
>>         EXCEPTION
>>           WHEN unique_violation THEN
>>             -- NULL -- do nothing
>>
>>         RETURN NULL; -- AFTER trigger results are ignored anyway
>>       END;
>
> exception is part of begin/exception/end; block
> so you will need one more begin and one more end;
>

Does this mean that the example given on pg. 798 of the manual is in
error, or have I misread it?


    -- Insert or update the summary row with the new values.
    <<insert_update>>
    LOOP
         UPDATE sales_summary_bytime
             SET amount_sold = amount_sold + delta_amount_sold,
                 units_sold = units_sold + delta_units_sold,
                 amount_cost = amount_cost + delta_amount_cost
             WHERE time_key = delta_time_key;
         EXIT insert_update WHEN found;
         BEGIN
             INSERT INTO sales_summary_bytime (
                          time_key,
                          amount_sold,
                          units_sold,
                          amount_cost)
                 VALUES (
                          delta_time_key,
                          delta_amount_sold,
                          delta_units_sold,
                          delta_amount_cost
                        );
             EXIT insert_update;
         EXCEPTION
             WHEN UNIQUE_VIOLATION THEN
                 -- do nothing
         END;
    END LOOP insert_update;
    RETURN NULL;
END;

-- 
***          E-Mail is NOT a SECURE channel          ***
James B. Byrne                mailto:ByrneJB@xxxxxxxxxxxxx
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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux