Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id C17579FB803 for ; Tue, 6 Mar 2007 13:29:23 -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 59652-10 for ; Tue, 6 Mar 2007 13:29:05 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.173]) by postgresql.org (Postfix) with ESMTP id 638FD9FB479 for ; Tue, 6 Mar 2007 13:29:04 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id k3so246336ugf for ; Tue, 06 Mar 2007 09:29:03 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=A9BLeoCTad3ekc++Em+T+QpNw55K0mceE71j3Ad+/7+9uMk6OU36hIX2C+v/YUKwWKBAS+1Po10IHXvvejybdxR9qEK8sUCBNa3D+IqV5PpBl1HYcPRYvlcQMuYttFt/zf9GSAraXs4kvGMHoaZ2c8eu1xWWJQxu+32dwvKSqhI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=J2pFszs5jPyYofx9g/9mx9bY7g2UOQes5UU8SUVZWRo+VD093HCAp7zrak9KV+1aj3nTWqeEdvfsvWGHk1raaACMwJ8eVOrzXgkEvIlNVLDxK9rd2XIasVLZSSf+AtADWWchAkBjRusFZrtrNfnFccIloqkJbj5e/j5KJPVcp0c= Received: by 10.67.106.3 with SMTP id i3mr2078463ugm.1173202143169; Tue, 06 Mar 2007 09:29:03 -0800 (PST) Received: by 10.67.94.13 with HTTP; Tue, 6 Mar 2007 09:29:03 -0800 (PST) Message-ID: <55c095e90703060929w745cd560g12426c986b75e430@mail.gmail.com> Date: Tue, 6 Mar 2007 14:29:03 -0300 From: "Ezequias Rodrigues da Rocha" To: "Richard Huxton" Subject: Re: Inc Cc: PostgreSQL In-Reply-To: <45EDA139.6070103@archonet.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <55c095e90703060855o228c0d0bm4b021826e3899ba5@mail.gmail.com> <45EDA139.6070103@archonet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/52 X-Sequence-Number: 27690 Thank you but I must inc an specific row. How to do that ? Ezequias 2007/3/6, Richard Huxton : > 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/