pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: getting back autonumber ... Another MsSQL Comparation Question
2+ messages / 2 participants
[nested] [flat]

* Re: getting back autonumber ... Another MsSQL Comparation Question
@ 2005-07-08 11:56 jimmy.olsen <jimmy.olsen@ig.com.br>
  2005-07-08 12:32 ` Re: getting back autonumber ... Another MsSQL Comparation Question Michael Fuhr <mike@fuhr.org>
  0 siblings, 1 reply; 2+ messages in thread

From: jimmy.olsen @ 2005-07-08 11:56 UTC (permalink / raw)
  To: pgsql-sql

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" <alvherre@alvh.no-ip.org>
To: "mail TechEvolution" <mail@techevolution.be>
Cc: <pgsql-sql@postgresql.org>
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 (<alvherre[a]alvh.no-ip.org>)
> 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
>




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: getting back autonumber ... Another MsSQL Comparation Question
  2005-07-08 11:56 Re: getting back autonumber ... Another MsSQL Comparation Question jimmy.olsen <jimmy.olsen@ig.com.br>
@ 2005-07-08 12:32 ` Michael Fuhr <mike@fuhr.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Fuhr @ 2005-07-08 12:32 UTC (permalink / raw)
  To: jimmy.olsen <jimmy.olsen@ig.com.br>; +Cc: pgsql-sql

[Please start a new thread when asking new questions.]

On Fri, Jul 08, 2005 at 08:56:56AM -0300, jimmy.olsen wrote:
>         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??

Your client interface should have a function to get the row count.
In libpq, for example, you can call PQcmdTuples(); in PL/pgSQL you
can use GET DIAGNOSTICS.  See the documentation for whatever interface
you're using.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-07-08 12:32 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-07-08 11:56 Re: getting back autonumber ... Another MsSQL Comparation Question jimmy.olsen <jimmy.olsen@ig.com.br>
2005-07-08 12:32 ` Michael Fuhr <mike@fuhr.org>

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