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)'
>
On 19/02/10 05:42, Yan Cheng Cheok wrote:
Of course, I get an error at line :
IF @@ROWCOUNT=0 THEN
May I know what is the correct PostgreSQL syntax for @@ROWCOUNT after update?
Best place for this sort of information is the manuals:
http://www.postgresql.org/docs/8.4/static/plpgsql-statement
By referring to article at :
http://blogs.msdn.com/miah/archive/2008/02/17/sql-if-exists-update-else-insert.aspx
I try to implement as follow :
CREATE OR REPLACE FUNCTION update_or_insert_statistic(int, text, text, double
precision)
RETURNS void AS
$BODY$DECLARE
_lotID ALIAS FOR $1;
_