From: | Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl> |
---|---|
To: | Yan Cheng Cheok <yccheok(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Getting number of affected row after performing update |
Date: | 2010-02-19 11:43:12 |
Message-ID: | 866F82F0-412C-4D07-97C8-46477D81B796@solfertje.student.utwente.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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!
From | Date | Subject | |
---|---|---|---|
Next Message | Heddon's Gate Hotel | 2010-02-19 13:10:29 | PostgreSQL fails to start |
Previous Message | Jignesh Shah | 2010-02-19 11:39:04 | Re: How to get the users name from users group? |