Skip site navigation (1) Skip section navigation (2)

Re: Return row after a Insert

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Return row after a Insert
Date: 2010-03-29 07:44:14
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
In response to Carel Combrink :
> I have a Table that looks something like this:
> 	Entry		integer PRIMARY KEY DEFAULT nextval('Number'),
> 	TimeInsert	timestamp DEFAULT current_timestamp,
> 	Severity	ENUM_Severity NOT NULL,
> 	String	varchar(512)
> );
> where Number is a SEQUENCE and ENUM_Severity is an ENUM
> There are 2 things I want to do.
> After an INSERT statement I want to be able to know what was the  
> 'Entry' number I just added. I was thinking on creating an AFTER  

You can use RETURNING *

Or just for the SERIAL currval().

Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

In response to

pgsql-novice by date

Next:From: Joshua TolleyDate: 2010-03-29 18:59:16
Subject: Re: Clustering/fail-over solution
Previous:From: Carel CombrinkDate: 2010-03-29 07:21:19
Subject: Return row after a Insert

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group