Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 91E7447645B for ; Wed, 27 Nov 2002 10:49:58 -0500 (EST) Received: from anchor-post-39.mail.demon.net (anchor-post-39.mail.demon.net [194.217.242.80]) by postgresql.org (Postfix) with ESMTP id 22174476668 for ; Wed, 27 Nov 2002 10:44:59 -0500 (EST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-39.mail.demon.net with esmtp (Exim 3.36 #2) id 18H4N5-00079U-0U; Wed, 27 Nov 2002 15:45:03 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 87BF617A1F; Wed, 27 Nov 2002 15:35:19 +0000 (GMT) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id E604417A1E; Wed, 27 Nov 2002 15:35:18 +0000 (GMT) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: Laurent Patureau , pgsql-sql@postgresql.org Subject: Re: Function and insert Date: Wed, 27 Nov 2002 15:35:15 +0000 User-Agent: KMail/1.4.3 References: <5.0.0.25.0.20021127120232.00c69aa0@pop.noos.fr> In-Reply-To: <5.0.0.25.0.20021127120232.00c69aa0@pop.noos.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211271535.16509.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/420 X-Sequence-Number: 10562 On Wednesday 27 Nov 2002 11:05 am, Laurent Patureau wrote: > Hi, > > I want to do a function that insert a row on a table like : > > CREATE FUNCTION ajout_secu(INT4) RETURNS OID > AS 'INSERT INTO test_2 VALUES($1);' > LANGUAGE 'SQL'; > > PG refuse to accept the type returns oid as the function is not a SELECT. > What can I do ? You're not returning anything - try something like: CREATE FUNCTION foo_ins(int4) RETURNS int4 AS=20 'INSERT INTO foo VALUES($1); SELECT $1;'=20 LANGUAGE 'SQL'; --=20 Richard Huxton