Re: Inc
| От | Richard Huxton |
|---|---|
| Тема | Re: Inc |
| Дата | |
| Msg-id | 45EDA139.6070103@archonet.com обсуждение исходный текст |
| Ответ на | Inc ("Ezequias Rodrigues da Rocha" <ezequias.rocha@gmail.com>) |
| Ответы |
Re: Inc
|
| Список | pgsql-sql |
Ezequias Rodrigues da Rocha wrote: > Hi list, > > There is any function to increment with 1 some field. > > 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(); -- Richard Huxton Archonet Ltd
В списке pgsql-sql по дате отправления: