Re: Getting number of affected row after performing update

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: Getting number of affected row after performing update
Дата
Msg-id 866F82F0-412C-4D07-97C8-46477D81B796@solfertje.student.utwente.nl
обсуждение исходный текст
Ответ на Getting number of affected row after performing update  (Yan Cheng Cheok <yccheok@yahoo.com>)
Список pgsql-general
On 19 Feb 2010, at 6:42, Yan Cheng Cheok wrote:

>    -- HOW?!?!
>    --ERROR:  column "rowcount" does not exist
>    --LINE 1: SELECT  @@ROWCOUNT=0
>    IF @@ROWCOUNT=0 THEN
>     EXECUTE 'INSERT INTO statistic(fk_lot_id, "value", measurement_type, statistic_type) VALUES ($1, $2, $3, $4)'
>     USING _lotID, _value, _measurementType, _statisticType;
>    END IF;

> May I know what is the correct PostgreSQL syntax for @@ROWCOUNT after update?


In plpgsql you can test for FOUND or NOT FOUND after performing a query:

    IF NOT FOUND THEN
        EXECUTE '...'
    END IF;

I think that's more convenient for your case than counting actual rows.

Alban Hertroys

--
Screwing up is the best way to attach something to the ceiling.


!DSPAM:737,4b7e795110442010528220!



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

Предыдущее
От: wilczarz1@op.pl
Дата:
Сообщение: Re: PERFORM not working properly, please help..
Следующее
От: Jignesh Shah
Дата:
Сообщение: Re: How to get the users name from users group?