Re: insert within pl/pgsql procedures: NOVICE question ? - Mailing list pgsql-general

From Tom Lane
Subject Re: insert within pl/pgsql procedures: NOVICE question ?
Date
Msg-id 1164.1013638897@sss.pgh.pa.us
Whole thread Raw
In response to insert within pl/pgsql procedures: NOVICE question ?  (Jeff Anto <antojf2001@yahoo.fr>)
List pgsql-general
=?iso-8859-1?q?Jeff=20Anto?= <antojf2001@yahoo.fr> writes:
> am I wrong or the optionnal syntax
> INSERT INTO foo(foo_col1) VALUES ('blahblah');
> dosen't work within a PLPGSQL-written function ?

Works for me:

regression=# create table foo(foo_col1 text);
CREATE
regression=# INSERT INTO foo(foo_col1) VALUES ('blahblah');
INSERT 1918283 1
regression=# create function doit(text) returns int as '
regression'# begin
regression'# INSERT INTO foo(foo_col1) VALUES ($1);
regression'# return 1;
regression'# end' language plpgsql;
CREATE
regression=# select doit('zzz');
 doit
------
    1
(1 row)

regression=# select * from foo;
 foo_col1
----------
 blahblah
 zzz
(2 rows)

regression=#

What are you doing differently?

            regards, tom lane

pgsql-general by date:

Previous
From: Darren Ferguson
Date:
Subject: Re: insert within pl/pgsql procedures: NOVICE question ?
Next
From: Stephan Szabo
Date:
Subject: Re: insert within pl/pgsql procedures: NOVICE question ?