Re: Inc
От | Andreas Kretschmer |
---|---|
Тема | Re: Inc |
Дата | |
Msg-id | 20070306174648.GA7677@KanotixBox обсуждение исходный текст |
Ответ на | Re: Inc ("Ezequias Rodrigues da Rocha" <ezequias.rocha@gmail.com>) |
Список | pgsql-sql |
Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com> schrieb: > Thank you but I must inc an specific row. How to do that ? Read the answer again. Please, no silly TOFU (german synonym for text above, fullquote below). > >> For example. I have a table with a field that on each update it > >> incrementes a field that is allways configured to 0 before the > >> starting of updates. > >Something like: > >CREATE FUNCTION my_autoinc() RETURNS TRIGGER AS $$ > >BEGIN > > NEW.counter := NEW.counter + 1; > > RETURN NEW; > >END; > >$$ LANGUAGE plpgsql; > >CREATE TRIGGER my_counter_trig BEFORE UPDATE ON my_table > >FOR EACH ROW EXECUTE PROCEDURE my_autoinc(); Your task is only to adapt this to your table-design. Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly." (unknow) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
В списке pgsql-sql по дате отправления: