From: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Inc |
Date: | 2007-03-06 17:46:49 |
Message-ID: | 20070306174648.GA7677@KanotixBox |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Ezequias Rodrigues da Rocha <ezequias(dot)rocha(at)gmail(dot)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°
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Kretschmer | 2007-03-06 17:54:07 | Re: Inc |
Previous Message | Steve Midgley | 2007-03-06 17:43:14 | Re: GiST index question: performance |