Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 124599FBA91 for ; Tue, 6 Mar 2007 13:46:18 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 78432-05 for ; Tue, 6 Mar 2007 13:46:08 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from 137086.vserver.de (vs137086.vserver.de [62.75.137.86]) by postgresql.org (Postfix) with ESMTP id 408A59FB9BF for ; Tue, 6 Mar 2007 13:46:07 -0400 (AST) Received: from a-kretschmer.de (p54B38776.dip0.t-ipconnect.de [84.179.135.118]) (authenticated bits=0) by 137086.vserver.de (8.12.8/8.12.8) with ESMTP id l26Hk2Eh016379 for ; Tue, 6 Mar 2007 18:46:03 +0100 Received: from kretschmer by a-kretschmer.de with local (Exim 4.61) (envelope-from ) id 1HOdkP-0005E9-1h for pgsql-sql@postgresql.org; Tue, 06 Mar 2007 18:46:49 +0100 Date: Tue, 6 Mar 2007 18:46:49 +0100 From: Andreas Kretschmer To: pgsql-sql@postgresql.org Subject: Re: Inc Message-ID: <20070306174648.GA7677@KanotixBox> References: <55c095e90703060855o228c0d0bm4b021826e3899ba5@mail.gmail.com> <45EDA139.6070103@archonet.com> <55c095e90703060929w745cd560g12426c986b75e430@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <55c095e90703060929w745cd560g12426c986b75e430@mail.gmail.com> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: mutt-ng 1.5.9i (Linux) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.5 tagged_above=0 required=5 tests=AWL, BAYES_50, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200703/55 X-Sequence-Number: 27693 Ezequias Rodrigues da Rocha 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°