Re: Inc - Mailing list pgsql-sql

From Ezequias Rodrigues da Rocha
Subject Re: Inc
Date
Msg-id 55c095e90703060929w745cd560g12426c986b75e430@mail.gmail.com
Whole thread Raw
In response to Re: Inc  (Richard Huxton <dev@archonet.com>)
Responses Re: Inc
Re: Inc
Re: Inc
List pgsql-sql
Thank you but I must inc an specific row. How to do that ?

Ezequias

2007/3/6, Richard Huxton <dev@archonet.com>:
> 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
>


-- 
Ezequias Rodrigues da Rocha
http://ezequiasrocha.blogspot.com/
use Mozilla Firefox:http://br.mozdev.org/firefox/


pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Inc
Next
From: Richard Broersma Jr
Date:
Subject: Re: Inc