Problem with FOUND
| От | A B |
|---|---|
| Тема | Problem with FOUND |
| Дата | |
| Msg-id | dbbf25900806260543w74650595y66f4e92067ff435a@mail.gmail.com обсуждение исходный текст |
| Ответы |
Re: Problem with FOUND
|
| Список | 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 по дате отправления: