Re: Function and insert

From: Richard Huxton <dev(at)archonet(dot)com>
To: Laurent Patureau <lpatureau(at)idfr(dot)net>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Function and insert
Date: 2002-11-27 15:35:15
Message-ID: 200211271535.16509.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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
'INSERT INTO foo VALUES($1); SELECT $1;'
LANGUAGE 'SQL';

--
Richard Huxton

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2002-11-27 16:15:58 Re: FreeBSD, Linux: select, select count(*) performance
Previous Message D'Arcy J.M. Cain 2002-11-27 12:51:57 Re: Casting Money To Numeric