Re: SQL stored function inserting and returning data in a row.

From: Marcin Stępnicki <mstepnicki(at)gmail(dot)com>
To: "Daniel Caune" <daniel(dot)caune(at)ubisoft(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: SQL stored function inserting and returning data in a row.
Date: 2008-01-11 11:15:00
Message-ID: 179149fe0801110315w24bd1da8lcdd13c8875265f40@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-sql

On Jan 11, 2008 4:23 AM, Daniel Caune <daniel(dot)caune(at)ubisoft(dot)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;
"

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Marcin Stępnicki 2008-01-11 11:19:17 Re: SQL stored function inserting and returning data in a row.
Previous Message Hocine Abir 2008-01-11 11:06:45 Re: [SQL] SQL stored function inserting and returning data in a row.

Browse pgsql-sql by date

  From Date Subject
Next Message Marcin Stępnicki 2008-01-11 11:19:17 Re: SQL stored function inserting and returning data in a row.
Previous Message Hocine Abir 2008-01-11 11:06:45 Re: [SQL] SQL stored function inserting and returning data in a row.