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

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 (view raw or flat)
Thread:
Lists: pgsql-adminpgsql-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

pgsql-admin by date

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

pgsql-sql by date

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

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