Re: Inc - Mailing list pgsql-sql

From Andreas Kretschmer
Subject Re: Inc
Date
Msg-id 20070306174648.GA7677@KanotixBox
Whole thread Raw
In response to Re: Inc  ("Ezequias Rodrigues da Rocha" <ezequias.rocha@gmail.com>)
List 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 by date:

Previous
From: Steve Midgley
Date:
Subject: Re: GiST index question: performance
Next
From: Andreas Kretschmer
Date:
Subject: Re: Inc