Re: Return row after a Insert
| От | A. Kretschmer |
|---|---|
| Тема | Re: Return row after a Insert |
| Дата | |
| Msg-id | 20100329074414.GC21944@a-kretschmer.de обсуждение |
| Ответ на | Return row after a Insert (Carel Combrink <s25291930@tuks.co.za>) |
| Список | pgsql-novice |
In response to Carel Combrink :
> I have a Table that looks something like this:
>
> CREATE TABLE My_Table(
> 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 *
http://www.postgresql.org/docs/current/static/sql-insert.html
Or just for the SERIAL currval().
Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 2EB0 389D 1DC2 3172 0C99
В списке pgsql-novice по дате отправления: