pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Laurent Patureau <lpatureau@idfr.net>
To: pgsql-sql@postgresql.org
Subject: Re: Function and insert
Date: Wed, 27 Nov 2002 15:35:15 +0000
Message-ID: <200211271535.16509.dev@archonet.com> (raw)
In-Reply-To: <5.0.0.25.0.20021127120232.00c69aa0@pop.noos.fr>
References: <5.0.0.25.0.20021127120232.00c69aa0@pop.noos.fr>

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



view thread (2+ messages)

Message-ID: <200211271535.16509.dev@archonet.com>
Permalink:  ../200211271535.16509.dev@archonet.com/
Also on:    postgresql.org/message-id/200211271535.16509.dev@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, lpatureau@idfr.net
  Subject: Re: Function and insert
  In-Reply-To: <200211271535.16509.dev@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox