Search Postgresql Archives

Re: Getting number of affected row after performing update

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

 



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!



-- 
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