pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Kretschmer <akretschmer@spamfence.net>
To: pgsql-sql@postgresql.org
Subject: Re: Inc
Date: Tue, 6 Mar 2007 18:46:49 +0100
Message-ID: <20070306174648.GA7677@KanotixBox> (raw)
In-Reply-To: <55c095e90703060929w745cd560g12426c986b75e430@mail.gmail.com>
References: <55c095e90703060855o228c0d0bm4b021826e3899ba5@mail.gmail.com>
	<45EDA139.6070103@archonet.com>
	<55c095e90703060929w745cd560g12426c986b75e430@mail.gmail.com>

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°



view thread (9+ messages)  latest in thread

Message-ID: <20070306174648.GA7677@KanotixBox>
Permalink:  ../20070306174648.GA7677@KanotixBox/
Also on:    postgresql.org/message-id/20070306174648.GA7677@KanotixBox

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: akretschmer@spamfence.net
  Subject: Re: Inc
  In-Reply-To: <20070306174648.GA7677@KanotixBox>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox