Problem with FOUND - Mailing list pgsql-general

From A B
Subject Problem with FOUND
Date
Msg-id dbbf25900806260543w74650595y66f4e92067ff435a@mail.gmail.com
Whole thread Raw
Responses Re: Problem with FOUND  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi.
I run a function

CREATE OR REPLACE FUNCTION addRating(tbl_ INTEGER,value_ INTEGER)
RETURNS void AS $$
DECLARE
    tablename TEXT;
    fieldname TEXT;
BEGIN
    tablename:='Rating_'||tbl_;
    fieldname:='val';
    EXECUTE 'UPDATE '||tablename||' SET '||fieldname||'='||value_||'
WHERE '||fieldname||'='||value_ ;
    IF NOT FOUND THEN
        EXECUTE 'INSERT INTO '||tablename||' ('||fieldname||') VALUES ('||value_||')';
    END IF;
END;
$$ LANGUAGE plpgsql;

The UPDATE command works fine (afterwards the table is updated) but it
seems that it do the insert even if it do the update.
I thought this was a correct useage of  "FOUND" so that it either do
the update or the insert, not both.
Can anyone help me spot the error?

pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: Unicode problem again
Next
From: Alvaro Herrera
Date:
Subject: Re: 0xc3 error Text Search Windows French