X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0A81E52AC6 for ; Fri, 8 Jul 2005 08:54:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98970-08 for ; Fri, 8 Jul 2005 11:54:29 +0000 (GMT) Received: from cliente12.ligaone.com.br (unknown [200.251.208.159]) by svr1.postgresql.org (Postfix) with ESMTP id 926A852AC1 for ; Fri, 8 Jul 2005 08:54:27 -0300 (ADT) Received: from cliente12 ([127.0.0.1]) by cliente12.ligaone.com.br with Microsoft SMTPSVC(5.0.2195.6713); Fri, 8 Jul 2005 08:57:40 -0300 Message-ID: <003c01c583b4$3e20b510$230a0a0a@ligaone.com.br> From: "jimmy.olsen" To: References: <42CD6B58.6060508@techevolution.be> <20050707180329.GA11332@alvh.no-ip.org> Subject: Re: getting back autonumber ... Another MsSQL Comparation Question Date: Fri, 8 Jul 2005 08:56:56 -0300 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1506 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 X-OriginalArrivalTime: 08 Jul 2005 11:57:40.0981 (UTC) FILETIME=[3E23C250:01C583B4] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.312 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST X-Spam-Level: * X-Archive-Number: 200507/64 X-Sequence-Number: 22042 Hi Listers, I need to know the number of affected (Inserted, deleted, updated) rows by a Query. In MsSQL I use SELECT @@ROWCOUNT, similar to SELECT @@IDENTITY. Is there any @@RowCount similar statement in PostGres?? Alessandro - Liga One Sistemas alessandro@ligaone.com.br ----- Original Message ----- From: "Alvaro Herrera" To: "mail TechEvolution" Cc: Sent: Thursday, July 07, 2005 3:03 PM Subject: Re: [SQL] getting back autonumber just inserted > On Thu, Jul 07, 2005 at 07:50:16PM +0200, mail TechEvolution wrote: > > hello > > > > i ame a newbie to PostGreSQL, I ame using PostGreSQL 8.0 > > (windowsinstaller) on a xp prof platform > > > > i would like to get back the autonumber from the last record inserted, > > for other SQL db (m$ sql db ...) i could use: > > SELECT @@ IDENTITY > > > > can someone help me by informing me what the SQL syntax is to be used > > with PostGreSQL db and get the same result, the last autonumber inserted? > > You use the currval() function, using the name of the involved sequence > as parameter. There is a pg_get_serial_sequence() function, to which > you give the table name and column name, and it will give you the > sequence name. > > -- > Alvaro Herrera () > Oh, oh, las chicas galacianas, lo harán por las perlas, > ˇY las de Arrakis por el agua! Pero si buscas damas > Que se consuman como llamas, ˇPrueba una hija de Caladan! (Gurney Halleck) > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly >