Re: Function and insert - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Function and insert
Date
Msg-id 200211271535.16509.dev@archonet.com
Whole thread Raw
In response to Function and insert  (Laurent Patureau <lpatureau@idfr.net>)
List 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


pgsql-sql by date:

Previous
From: "D'Arcy J.M. Cain"
Date:
Subject: Re: Casting Money To Numeric
Next
From: Tom Lane
Date:
Subject: Re: [GENERAL] FreeBSD, Linux: select, select count(*) performance