Re: SQL stored function inserting and returning data in a row. - Mailing list pgsql-sql

From Marcin Stępnicki
Subject Re: SQL stored function inserting and returning data in a row.
Date
Msg-id 179149fe0801110315w24bd1da8lcdd13c8875265f40@mail.gmail.com
Whole thread Raw
In response to SQL stored function inserting and returning data in a row.  ("Daniel Caune" <daniel.caune@ubisoft.com>)
List pgsql-sql
On Jan 11, 2008 4:23 AM, Daniel Caune <daniel.caune@ubisoft.com> wrote:
> Hi,
>
> Is there any way to define a SQL stored function that inserts a row in a
> table and returns the serial generated?

Maybe you just need INSERT ... RETURNING?

http://www.postgresql.org/docs/8.2/interactive/sql-insert.html

" Insert a single row into table distributors, returning the sequence
number generated by the DEFAULT clause:

INSERT INTO distributors (did, dname) VALUES (DEFAULT, 'XYZ Widgets')  RETURNING did;
"


pgsql-sql by date:

Previous
From: Gerardo Herzig
Date:
Subject: Re: SQL stored function inserting and returning data in a row.
Next
From: "Marcin Stępnicki"
Date:
Subject: Re: SQL stored function inserting and returning data in a row.