Обсуждение: Problem with function invocation
Hello.
When I create next function:
create function pilpot() returns integer as '
declare
foo integer;
begin
foo = insert into aviso(user) values(1);
return foo;
end;
' language 'plpgsql';
And try to invoque with:
# select pilpot();
I get next error:
ERROR: parser: parse error at or near "("
Where is the problem with this?
Thanks a lot.
David
DaVinci <bombadil@wanadoo.es> writes:
> foo = insert into aviso(user) values(1);
INSERT doesn't return a value AFAIK ...
regards, tom lane
On Mon, 16 Apr 2001, DaVinci wrote: > Hello. > > When I create next function: > > create function pilpot() returns integer as ' > declare > foo integer; > begin > foo = insert into aviso(user) values(1); > return foo; > end; > ' language 'plpgsql'; > What exactly are you trying to return from the function? Removing the foo declaration and foo = from the insert line (and double quoting the reserved word user) on 7.1 makes the function work for me (I just returned 1).
On Mon, Apr 16, 2001 at 03:43:23PM +0200, DaVinci wrote:
> Hello.
>
> When I create next function:
>
> create function pilpot() returns integer as '
> declare
> foo integer;
> begin
> foo = insert into aviso(user) values(1);
> return foo;
> end;
> ' language 'plpgsql';
don't assignments have to be pascal-style, with a colon?
var := expression + some / value ;
and then, doesn't the rhs (right-hand side) have to return a
value? i don't think insert does return anything pertinent
(except in psql where you can see the oid and the 'record count'
[or is it more like an 'activity count'?]). <== do i get a prize
for the most-consecutive punctuation within an english-text
paragraph? :)
--
don't visit this page. it's bad for you. take my expert word for it.
http://www.salon.com/people/col/pagl/2001/03/21/spring/index1.html
will@serensoft.com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!