pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedFunction and insert
2+ messages / 2 participants
[nested] [flat]
* Function and insert
@ 2002-11-27 11:05 Laurent Patureau <lpatureau@idfr.net>
0 siblings, 1 reply; 2+ messages in thread
From: Laurent Patureau @ 2002-11-27 11:05 UTC (permalink / raw)
To: pgsql-sql
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 ?
thanks for your help,
LP
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Function and insert
@ 2002-11-27 15:35 Richard Huxton <dev@archonet.com>
parent: Laurent Patureau <lpatureau@idfr.net>
0 siblings, 0 replies; 2+ messages in thread
From: Richard Huxton @ 2002-11-27 15:35 UTC (permalink / raw)
To: Laurent Patureau <lpatureau@idfr.net>; 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2002-11-27 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-11-27 11:05 Function and insert Laurent Patureau <lpatureau@idfr.net>
2002-11-27 15:35 ` Richard Huxton <dev@archonet.com>
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